|
@@ -225,6 +225,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public static String plusDate(int day, Date current, String format)
|
|
|
+ {
|
|
|
+
|
|
|
+ // 创建一个Calendar实例,并将日期设置为今天
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(current);
|
|
|
+ // 将日期设置为前一天
|
|
|
+ calendar.add(Calendar.DATE, day);
|
|
|
+
|
|
|
+ // 转换
|
|
|
+ return parseDateToStr(format, calendar.getTime());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public static List<String> getAllDatesBetween(LocalDate startDate, LocalDate endDate) {
|
|
|
List<String> dates = new ArrayList<>();
|
|
|
LocalDate currentDate = startDate;
|
|
@@ -340,7 +354,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
|
/*System.out.println(getMonthsBefore("2024-02", 2));
|
|
|
System.out.println();
|
|
|
System.out.println(getNYearSameDay("2024-02-01", 1));
|
|
|
- System.out.println(getNYearSameMonth("2024-02", 1));*/
|
|
|
+ System.out.println(getNYearSameMonth("2024-02", 1));
|
|
|
List<String> allDatesInRangeDate = getAllDatesInRangeDate(date1, date);
|
|
|
for (String s : allDatesInRangeDate) {
|
|
|
System.out.println(s);
|
|
@@ -355,6 +369,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ System.out.println(plusDate(-1, nowDate, YYYY_MM_DD));
|
|
|
}
|
|
|
}
|