修改互联网岗位上传
This commit is contained in:
@@ -265,4 +265,29 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
System.out.println("当前时间+3个月:" + sdf.format(threeMonthsLater));
|
||||
return sdf.format(threeMonthsLater);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期往后推3个月的格式化字符串
|
||||
* @param baseDate 基准日期(传入要计算的原始日期,不再取系统当前时间)
|
||||
* @param fmt 日期格式化模板,例:yyyy-MM-dd、yyyy-MM-dd HH:mm:ss
|
||||
* @return 加3个月后的日期字符串
|
||||
*/
|
||||
/**
|
||||
* 获取基准日期3个月之后的日期字符串
|
||||
* @param baseDate 基准日期,传null则自动使用当前系统时间
|
||||
* @param fmt 日期格式化模板,如 yyyy-MM-dd
|
||||
* @return 偏移3个月后的格式化日期
|
||||
*/
|
||||
public static String getMonthThree(Date baseDate, String fmt) {
|
||||
// 初始化日历,默认就是系统当前时间
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
// 判断:传入日期不为空,就覆盖基准时间;为空则保留默认当前时间
|
||||
if (baseDate != null) {
|
||||
calendar.setTime(baseDate);
|
||||
}
|
||||
// 向后加3个月
|
||||
calendar.add(Calendar.MONTH, 3);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(fmt);
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user