LocalDate localDate = LocalDate.of(2023,Calendar.APRIL,24);
// localDate = localDate.minusMonths(1);//月份-1
// 获取当前月的第一天
// LocalDate firstDay = localDate.with(TemporalAdjusters.firstDayOfMonth());
// System.out.println(firstDay);
// 获取当前月的最后一天
LocalDate lastDay = localDate.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth());
// 第一种格式化 直接格式化
String date = lastDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
System.out.println(date);
// 第二种格式化 先转位Date再用SimpleDateFormat格式化
Date endTime = Date.from(lastDay.atStartOfDay(ZoneId.systemDefault()).toInstant());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(format.format(endTime));