Commit 0deca752 authored by 刘林's avatar 刘林

fix:(jg) 设备注册代码生成未考虑闰年,导致2月29非法日期bug处理

parent 690b9ca7
......@@ -15,11 +15,15 @@ public class DateUtils {
public static Date calculateEndOfMonth(Date currentDate) {
LocalDateTime localDateTime = toLocalDateTime(currentDate);
LocalDateTime endOfMonth = localDateTime.with(localDateTime.withDayOfMonth(localDateTime.getMonth().maxLength())
// 获取当前月份的实际天数(考虑闰年)
int lastDay = localDateTime.getMonth().length(localDateTime.toLocalDate().isLeapYear());
// 直接设置为本月最后一天 23:59:59.999
LocalDateTime endOfMonth = localDateTime
.withDayOfMonth(lastDay)
.withHour(23)
.withMinute(59)
.withSecond(59)
.withNano(999999999));
.withNano(999_999_999);
return toDate(endOfMonth);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment