mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -2,6 +2,7 @@ package cn.hutool.cron.pattern;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -13,7 +14,9 @@ public class CronPatternNextMatchTest {
|
||||
CronPattern pattern = new CronPattern("23 12 * 12 * * *");
|
||||
//noinspection ConstantConditions
|
||||
final Calendar calendar = pattern.nextMatchAfter(
|
||||
DateUtil.parse("2022-04-12 09:12:23").toCalendar());
|
||||
DateUtil.parse("2022-04-12 09:12:12").toCalendar());
|
||||
|
||||
Console.log(DateUtil.date(calendar));
|
||||
Assert.assertTrue(pattern.match(calendar, true));
|
||||
}
|
||||
}
|
||||
|
@@ -122,6 +122,14 @@ public class CronPatternTest {
|
||||
assertMatch(pattern, "2017-02-19 04:00:33");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void patternNegativeTest() {
|
||||
// -4表示倒数的数字,此处在小时上,-4表示 23 - 4,为19
|
||||
CronPattern pattern = CronPattern.of("* 0 -4 * * ?");
|
||||
assertMatch(pattern, "2017-02-09 19:00:00");
|
||||
assertMatch(pattern, "2017-02-19 19:00:33");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rangePatternTest() {
|
||||
CronPattern pattern = CronPattern.of("* 20/2 * * * ?");
|
||||
|
Reference in New Issue
Block a user