|
@@ -219,6 +219,26 @@ public class DateUtils {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取近6个月的日期范围
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static List<MonthRange> getRecentSixMonthRanges() {
|
|
|
|
|
+ List<MonthRange> result = new ArrayList<>();
|
|
|
|
|
+ YearMonth currentYearMonth = YearMonth.now();
|
|
|
|
|
+ YearMonth startYearMonth = currentYearMonth.minusMonths(5);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
|
|
+ YearMonth yearMonth = startYearMonth.plusMonths(i);
|
|
|
|
|
+ String formattedMonth = yearMonth.toString(); // 格式为 yyyy-MM
|
|
|
|
|
+ LocalDateTime start = yearMonth.atDay(1).atStartOfDay();
|
|
|
|
|
+ LocalDateTime end = yearMonth.atEndOfMonth().atTime(LocalTime.MAX);
|
|
|
|
|
+ result.add(new MonthRange(formattedMonth, start, end, 0));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static class MonthRange {
|
|
public static class MonthRange {
|
|
|
private String yearMonth;
|
|
private String yearMonth;
|
|
|
private LocalDateTime start;
|
|
private LocalDateTime start;
|