mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-08-18 20:38:02 +08:00
修复CronPattern.nextMatchAfter匹配初始值问题
This commit is contained in:
@@ -16,7 +16,7 @@ public class CronPatternNextMatchTest {
|
||||
CronPattern pattern = new CronPattern("* * * * * * *");
|
||||
DateTime date = DateUtil.truncate(DateUtil.date(), DateField.SECOND);
|
||||
Calendar calendar = pattern.nextMatchAfter(date.toCalendar());
|
||||
Assert.assertEquals(date.getTime(), DateUtil.date(calendar).getTime());
|
||||
Assert.assertEquals(date.getTime() + 1000, DateUtil.date(calendar).getTime());
|
||||
|
||||
// 匹配所有分,返回下一分钟
|
||||
pattern = new CronPattern("0 * * * * * *");
|
||||
|
@@ -0,0 +1,19 @@
|
||||
package cn.hutool.cron.pattern;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class IssueI9FQUATest {
|
||||
@Test
|
||||
public void nextDateAfterTest() {
|
||||
final String cron = "0/5 * * * * ?";
|
||||
final Calendar calendar = CronPattern.of(cron).nextMatchAfter(
|
||||
DateUtil.parse("2024-01-01 00:00:00").toCalendar());
|
||||
|
||||
//Console.log(DateUtil.date(calendar));
|
||||
Assert.assertEquals("2024-01-01 00:00:05", DateUtil.date(calendar).toString());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user