fix: LocalDateTimeUtils.getDateRangeList计算季度区间有误

This commit is contained in:
dhb52 2024-04-06 15:14:20 +08:00
parent 44c22e1ef5
commit 84140c52b0

View File

@ -249,8 +249,11 @@ public class LocalDateTimeUtils {
break;
case DateIntervalEnum.QUARTER:
while (startTime.isBefore(endTime)) {
LocalDateTime quarterEnd = startTime.withMonth(getQuarterOfYear(startTime) * 3 + 1)
.withDayOfMonth(1).minusNanos(1);
int quarterOfYear = getQuarterOfYear(startTime);
LocalDateTime quarterEnd =
quarterOfYear == 4
? startTime.with(TemporalAdjusters.lastDayOfYear()).plusDays(1).minusNanos(1)
: startTime.withMonth(quarterOfYear * 3 + 1).withDayOfMonth(1).minusNanos(1);
timeRanges.add(new LocalDateTime[]{startTime, quarterEnd});
startTime = quarterEnd.plusNanos(1);
}