【优化】降低 JDK 21 最低到 17 版本

pull/102/MERGE
YunaiV 2024-05-01 01:44:07 +08:00
parent ef63cb37b7
commit 78e151d4ee
2 changed files with 11 additions and 11 deletions

View File

@ -31,7 +31,7 @@
<properties> <properties>
<revision>2.0.1-snapshot</revision> <revision>2.0.1-snapshot</revision>
<!-- Maven 相关 --> <!-- Maven 相关 -->
<java.version>21</java.version> <java.version>17</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source> <maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.target>${java.version}</maven.compiler.target>
<maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version> <maven-surefire-plugin.version>3.2.2</maven-surefire-plugin.version>

View File

@ -227,27 +227,27 @@ public class LocalDateTimeUtils {
// 2. 循环,生成时间范围 // 2. 循环,生成时间范围
List<LocalDateTime[]> timeRanges = new ArrayList<>(); List<LocalDateTime[]> timeRanges = new ArrayList<>();
switch (intervalEnum) { switch (intervalEnum) {
case DateIntervalEnum.DAY: case DAY:
while (startTime.isBefore(endTime)) { while (startTime.isBefore(endTime)) {
timeRanges.add(new LocalDateTime[]{startTime, startTime.plusDays(1).minusNanos(1)}); timeRanges.add(new LocalDateTime[]{startTime, startTime.plusDays(1).minusNanos(1)});
startTime = startTime.plusDays(1); startTime = startTime.plusDays(1);
} }
break; break;
case DateIntervalEnum.WEEK: case WEEK:
while (startTime.isBefore(endTime)) { while (startTime.isBefore(endTime)) {
LocalDateTime endOfWeek = startTime.with(DayOfWeek.SUNDAY).plusDays(1).minusNanos(1); LocalDateTime endOfWeek = startTime.with(DayOfWeek.SUNDAY).plusDays(1).minusNanos(1);
timeRanges.add(new LocalDateTime[]{startTime, endOfWeek}); timeRanges.add(new LocalDateTime[]{startTime, endOfWeek});
startTime = endOfWeek.plusNanos(1); startTime = endOfWeek.plusNanos(1);
} }
break; break;
case DateIntervalEnum.MONTH: case MONTH:
while (startTime.isBefore(endTime)) { while (startTime.isBefore(endTime)) {
LocalDateTime endOfMonth = startTime.with(TemporalAdjusters.lastDayOfMonth()).plusDays(1).minusNanos(1); LocalDateTime endOfMonth = startTime.with(TemporalAdjusters.lastDayOfMonth()).plusDays(1).minusNanos(1);
timeRanges.add(new LocalDateTime[]{startTime, endOfMonth}); timeRanges.add(new LocalDateTime[]{startTime, endOfMonth});
startTime = endOfMonth.plusNanos(1); startTime = endOfMonth.plusNanos(1);
} }
break; break;
case DateIntervalEnum.QUARTER: case QUARTER:
while (startTime.isBefore(endTime)) { while (startTime.isBefore(endTime)) {
int quarterOfYear = getQuarterOfYear(startTime); int quarterOfYear = getQuarterOfYear(startTime);
LocalDateTime quarterEnd = quarterOfYear == 4 LocalDateTime quarterEnd = quarterOfYear == 4
@ -257,7 +257,7 @@ public class LocalDateTimeUtils {
startTime = quarterEnd.plusNanos(1); startTime = quarterEnd.plusNanos(1);
} }
break; break;
case DateIntervalEnum.YEAR: case YEAR:
while (startTime.isBefore(endTime)) { while (startTime.isBefore(endTime)) {
LocalDateTime endOfYear = startTime.with(TemporalAdjusters.lastDayOfYear()).plusDays(1).minusNanos(1); LocalDateTime endOfYear = startTime.with(TemporalAdjusters.lastDayOfYear()).plusDays(1).minusNanos(1);
timeRanges.add(new LocalDateTime[]{startTime, endOfYear}); timeRanges.add(new LocalDateTime[]{startTime, endOfYear});
@ -290,16 +290,16 @@ public class LocalDateTimeUtils {
// 2. 循环,生成时间范围 // 2. 循环,生成时间范围
switch (intervalEnum) { switch (intervalEnum) {
case DateIntervalEnum.DAY: case DAY:
return LocalDateTimeUtil.format(startTime, DatePattern.NORM_DATE_PATTERN); return LocalDateTimeUtil.format(startTime, DatePattern.NORM_DATE_PATTERN);
case DateIntervalEnum.WEEK: case WEEK:
return LocalDateTimeUtil.format(startTime, DatePattern.NORM_DATE_PATTERN) return LocalDateTimeUtil.format(startTime, DatePattern.NORM_DATE_PATTERN)
+ StrUtil.format("(第 {} 周)", LocalDateTimeUtil.weekOfYear(startTime)); + StrUtil.format("(第 {} 周)", LocalDateTimeUtil.weekOfYear(startTime));
case DateIntervalEnum.MONTH: case MONTH:
return LocalDateTimeUtil.format(startTime, DatePattern.NORM_MONTH_PATTERN); return LocalDateTimeUtil.format(startTime, DatePattern.NORM_MONTH_PATTERN);
case DateIntervalEnum.QUARTER: case QUARTER:
return StrUtil.format("{}-Q{}", startTime.getYear(), getQuarterOfYear(startTime)); return StrUtil.format("{}-Q{}", startTime.getYear(), getQuarterOfYear(startTime));
case DateIntervalEnum.YEAR: case YEAR:
return LocalDateTimeUtil.format(startTime, DatePattern.NORM_YEAR_PATTERN); return LocalDateTimeUtil.format(startTime, DatePattern.NORM_YEAR_PATTERN);
default: default:
throw new IllegalArgumentException("Invalid interval: " + interval); throw new IllegalArgumentException("Invalid interval: " + interval);