Browse Source

提交日期工具类

develop
wanjing 9 months ago
parent
commit
5458400058
1 changed files with 0 additions and 20 deletions
  1. +0
    -20
      tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java

+ 0
- 20
tuoheng-common/tuoheng-common-core/src/main/java/com/tuoheng/common/core/utils/DateUtils.java View File

@@ -445,24 +445,4 @@ public final class DateUtils extends org.apache.commons.lang3.time.DateUtils {
return localDate.getMonthValue();
}

/**
* 获得多少个月以前(正数)或以后(负数)的时间,格式化成yyyy-MM-dd HH:mm:ss:SS
*/
public static String getMonthBefore(int month) {
Calendar calendar = Calendar.getInstance();//日历对象
calendar.setTime(date); //设置当前日期
calendar.add(Calendar.MONTH, month);//为负月份减,为正月份加
return sdf.format(calendar.getTime());
}

/**
* 获得多少年以前(正数)或以后(负数)的时间,格式化成yyyy-MM-dd HH:mm:ss:SS
*/
public static String getYearBefore(int year) {
Calendar calendar = Calendar.getInstance();//日历对象
calendar.setTime(date); //设置当前日期
calendar.add(Calendar.YEAR, year); //为负年减,为年份加
return sdf.format(calendar.getTime());
}

}

Loading…
Cancel
Save