public static void main(String[] args) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
// 计算一个月前的日期
LocalDate oneMonthAgo = currentDate.minus(Period.ofMonths(0)).minus(Period.ofDays(30));
// 计算去年同一年月日的日期
LocalDate lastYearSameDay = currentDate.minusYears(1);
LocalDate lastYearSameDays = currentDate.minusYears(1).minus(Period.ofMonths(1).minus(Period.ofDays(1)));
// 格式化日期
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String endDate = currentDate.format(formatter);
String startDate = oneMonthAgo.format(formatter);
String prevEndDate= lastYearSameDay.format(formatter);
String prevStartDate = lastYearSameDays.format(formatter);
List<String> dateRange = new ArrayList<>();
dateRange.add(startDate);
dateRange.add(endDate);
dateRange.add(prevStartDate);
dateRange.add(prevEndDate);
System.out.println(dateRange);
}