This commit is contained in:
Looly
2024-04-22 00:32:53 +08:00
parent 28ca5f2f54
commit ad2d10223d
3 changed files with 42 additions and 21 deletions

View File

@@ -100,6 +100,18 @@ public class CronPatternNextMatchTest {
Assertions.assertEquals("2022-01-12 00:12:23", DateUtil.date(calendar).toString());
}
@Test
public void nextMatchAfterTest2(){
final CronPattern pattern = new CronPattern("23 12 * 12 * * *");
// 秒超出规定值的最大值,分不变,小时+1秒和分使用最小值
//noinspection ConstantConditions
final Calendar calendar = pattern.nextMatchAfter(
DateUtil.parse("2022-04-12 09:12:24").toCalendar());
Assertions.assertTrue(pattern.match(calendar, true));
Assertions.assertEquals("2022-04-12 10:12:23", DateUtil.date(calendar).toString());
}
@Test
public void nextMatchAfterByWeekTest(){
final CronPattern pattern = new CronPattern("1 1 1 * * Sat *");

View File

@@ -14,7 +14,6 @@ package org.dromara.hutool.cron.pattern;
import org.dromara.hutool.core.date.DateTime;
import org.dromara.hutool.core.date.DateUtil;
import org.dromara.hutool.core.lang.Console;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;