Commit e6a2add1 authored by yanzg's avatar yanzg

增加日期处理

parent 33ac50cc
......@@ -435,7 +435,7 @@ public class DateHelper {
*
* @param date 当前日期
* @param year 需要增加的年份
* @return 增加年份后的值
* @return 增加后的值
*/
public static Date addYear(Date date, int year) {
Calendar cal = Calendar.getInstance();
......@@ -444,6 +444,34 @@ public class DateHelper {
return cal.getTime();
}
/**
* 增加月份处理
*
* @param date 当前日期
* @param month 需要增加的月份
* @return 增加之后的值
*/
public static Date addMonth(Date date, int month) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MONTH, month);
return cal.getTime();
}
/**
* 增加日期处理
*
* @param date 当前日期
* @param day 需要增加的日期
* @return 增加之后的值
*/
public static Date addDay(Date date, int day) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, day);
return cal.getTime();
}
/**
* 获取当前时间,精准到秒,格式为: yyyy-MM-dd HH:mm:ss
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment