Revert "Fix 4006"

This commit is contained in:
Golden Looly
2025-08-20 17:48:47 +08:00
committed by GitHub
parent 7028fad775
commit 5dfbdbbd6c
4 changed files with 4 additions and 49 deletions

View File

@@ -18,10 +18,6 @@ public class BoolArrayMatcher implements PartMatcher {
* 用户定义此字段的最小值
*/
private final int minValue;
/**
* 用户定义此字段的最大值
*/
private final int maxValue;
private final boolean[] bValues;
/**
@@ -33,15 +29,13 @@ public class BoolArrayMatcher implements PartMatcher {
Assert.isTrue(CollUtil.isNotEmpty(intValueList), "Values must be not empty!");
bValues = new boolean[Collections.max(intValueList) + 1];
int min = Integer.MAX_VALUE;
int max = Integer.MIN_VALUE;
for (Integer value : intValueList) {
min = Math.min(min, value);
max = Math.max(max, value);
bValues[value] = true;
}
this.minValue = min;
this.maxValue = max;
}
@Override
public boolean match(Integer value) {
if (null == value || value >= bValues.length) {
@@ -75,14 +69,6 @@ public class BoolArrayMatcher implements PartMatcher {
public int getMinValue() {
return this.minValue;
}
/**
* 获取表达式定义的最大值
*
* @return 最大值
*/
public int getMaxValue() {
return this.maxValue;
}
@Override
public String toString() {

View File

@@ -50,19 +50,8 @@ public class DayOfMonthMatcher extends BoolArrayMatcher {
return value == Month.getLastDay(month - 1, isLeapYear);
}
@Deprecated
public boolean isLast() {
return match(31);
}
/**
* 检查value是否大于等于这个月的最大天
* @param value 被检查的值
* @return
*/
public boolean isLastDay(int value) {
if(value>=getMaxValue()) return true;
return false;
}
}

View File

@@ -192,7 +192,7 @@ public class PatternMatcher {
// pr#1189
if (i == Part.DAY_OF_MONTH.ordinal()
&& matchers[i] instanceof DayOfMonthMatcher
&& ((DayOfMonthMatcher) matchers[i]).isLastDay(values[i])) {
&& ((DayOfMonthMatcher) matchers[i]).isLast()) {
int newMonth = newValues[Part.MONTH.ordinal()];
int newYear = newValues[Part.YEAR.ordinal()];
nextValue = getLastDay(newMonth, newYear);
@@ -226,7 +226,7 @@ public class PatternMatcher {
continue;
} else if (i == Part.DAY_OF_MONTH.ordinal()
&& matchers[i] instanceof DayOfMonthMatcher
&& ((DayOfMonthMatcher) matchers[i]).isLastDay(values[i])) {
&& ((DayOfMonthMatcher) matchers[i]).isLast()) {
int newMonth = newValues[Part.MONTH.ordinal()];
int newYear = newValues[Part.YEAR.ordinal()];
nextValue = getLastDay(newMonth, newYear);
@@ -259,7 +259,7 @@ public class PatternMatcher {
part = Part.of(i);
if (part == Part.DAY_OF_MONTH
&& get(part) instanceof DayOfMonthMatcher
&& ((DayOfMonthMatcher) get(part)).isLastDay(values[i])) {
&& ((DayOfMonthMatcher) get(part)).isLast()) {
int newMonth = values[Part.MONTH.ordinal()];
int newYear = values[Part.YEAR.ordinal()];
values[i] = getLastDay(newMonth, newYear);

View File

@@ -1,20 +0,0 @@
package cn.hutool.cron.pattern;
import cn.hutool.core.date.DateTime;
import org.junit.jupiter.api.Test;
import java.util.Date;
public class Issue4006Test {
@Test
void testCron() {
// String cron = "0 0 0 */1 * ?";
String cron = "0 0 0 */1 * ? *";
DateTime judgeTime = DateTime.of(new Date());
CronPattern cronPattern = new CronPattern(cron);
System.out.println("cronPattern = " + cronPattern);
Date nextDate = CronPatternUtil.nextDateAfter(cronPattern, judgeTime, true);
System.out.println("nextDate = " + nextDate);
}
}