|
|
|
|
@ -331,7 +331,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
|
|
|
|
resultMap.put("lastMonthEnd", now.withDayOfMonth(1).minusDays(1).with(LocalTime.MAX).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
// 去年的开始和结束时间
|
|
|
|
|
resultMap.put("lastYearStart", now.minusYears(1).withDayOfYear(1).with(LocalTime.MIN).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
resultMap.put("lastYearEnd", now.minusYears(1).withDayOfYear(lastYear.minusYears(1).lengthOfYear()).with(LocalTime.MAX).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
String lastYearEnd = now.minusYears(1)
|
|
|
|
|
// 修正:用lastYear.lengthOfYear()获取去年的总天数,定位到去年最后一天
|
|
|
|
|
.withDayOfYear(lastYear.lengthOfYear())
|
|
|
|
|
// 设置为当天最后一刻
|
|
|
|
|
.with(LocalTime.MAX)
|
|
|
|
|
// 格式化为指定字符串(会自动截断纳秒,只保留到秒)
|
|
|
|
|
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
resultMap.put("lastYearEnd", lastYearEnd);
|
|
|
|
|
// 去年当月的开始和结束时间
|
|
|
|
|
LocalDateTime nowNew = LocalDateTime.now();
|
|
|
|
|
LocalDate lastYearMonth = LocalDate.now().minusYears(1).withMonth(nowNew.getMonthValue());
|
|
|
|
|
|