• java dateutil工具类Date.add()


    1则代表的是对年份操作,2是对月份操作,3是对星期操作,5是对日期操作,11是对小时操作,12是对分钟操作,13是对秒操作,14是对毫秒操作。
      public static Date addYears(Date date, int amount)  
        {  
            return add(date, 1, amount);  
        }  
      
        public static Date addMonths(Date date, int amount)  
        {  
            return add(date, 2, amount);  
        }  
      
        public static Date addWeeks(Date date, int amount)  
        {  
            return add(date, 3, amount);  
        }  
      
        public static Date addDays(Date date, int amount)  
        {  
            return add(date, 5, amount);  
        }  
      
        public static Date addHours(Date date, int amount)  
        {  
            return add(date, 11, amount);  
        }  
      
        public static Date addMinutes(Date date, int amount)  
        {  
            return add(date, 12, amount);  
        }  
      
        public static Date addSeconds(Date date, int amount)  
        {  
            return add(date, 13, amount);  
        }  
      
        public static Date addMilliseconds(Date date, int amount)  
        {  
            return add(date, 14, amount);  
        }  
      
        private static Date add(Date date, int calendarField, int amount)  
        {  
            if(date == null)  
            {  
                throw new IllegalArgumentException("The date must not be null");  
            } else  
            {  
                Calendar c = Calendar.getInstance();  
                c.setTime(date);  
                c.add(calendarField, amount);  
                return c.getTime();  
            }  
        
  • 相关阅读:
    vue打包不显示或图片不显示配置
    Vue::is特性用法
    毕业实习报告
    前端vscode常用快捷键总结
    1. 变量常量
    信息收集之CMS指纹识别
    4. EIGRP的复合度量值
    3. EIGRP报文,三张表,邻居建立
    信息收集之目录扫描
    2. EIGRP路由单播邻居和被动接口
  • 原文地址:https://www.cnblogs.com/shanheyongmu/p/12448748.html
Copyright © 2020-2023  润新知