NextExecution time with quartz definition fails when date if the end of the month

NextExecution time with quartz definition fails when date if the end of the month

目前,我每分钟都有一个 cron 作业计划,但是一旦日期是月底,nextExecution 方法就无法提供正确的日期。

test("check execution times") {
// make sure the execution times are correct
val expression = "0 * * ? * * *" // every minute (the top of the minute)
val currentTime = "2019-12-31T00:00:00.000Z" // get current time
val expectedNextExecution = "2019-12-31T00:01:00.000Z" // get current time
val cron = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)).parse(expression)
val executor = ExecutionTime.forCron(cron)
val actualNextExecution = executor.nextExecution(DateTime.parse(currentTime)).toString // call nextExecution which should give us the next top of the minute
// check if nextExecution has correct next execution time
assert(actualNextExecution == expectedNextExecution, "Wrong execution time")
}

结果:

Expected :"20[19-12-31T00:01]:00.000Z" 
Wrong execution time Actual   :"20[20-01-01T00:00]:00.000Z"

答案是更新我的 cron-utils 版本。

之前在: 4.1.0

问题已解决: 9.0.2

谢谢