there is a bug in the lib when cron switches to next month and a fixed month is set in the cron expression. Here are some unit tests which show the problem. Instead of switching to 00:50 the calculated time is 23:50.
public void testSPSTriggerProblemSameMonth() {
assertEquals(ZonedDateTime.parse("2020-01-02T00:50:00Z"),
new CronExpression("00 50 * 1-8 1 *")
.nextTimeAfter(ZonedDateTime.parse("2020-01-01T23:50:00Z")));
}
public void testSPSTriggerProblemNextMonth() {
assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
new CronExpression("00 50 * 1-8 2 *")
.nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextYear() {
assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
new CronExpression("00 50 * 1-8 1 *")
.nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextMonthMonthAst() {
assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
new CronExpression("00 50 * 1-8 * *")
.nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextYearMonthAst() {
assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
new CronExpression("00 50 * 1-8 * *")
.nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextMonthDayAst() {
assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
new CronExpression("00 50 * * 2 *")
.nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextYearDayAst() {
assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
new CronExpression("00 50 * * 1 *")
.nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextMonthAllAst() {
assertEquals(ZonedDateTime.parse("2020-02-01T00:50:00Z"),
new CronExpression("00 50 * * * *")
.nextTimeAfter(ZonedDateTime.parse("2020-01-31T23:50:00Z")));
}
public void testSPSTriggerProblemNextYearAllAst() {
assertEquals(ZonedDateTime.parse("2020-01-01T00:50:00Z"),
new CronExpression("00 50 * * * *")
.nextTimeAfter(ZonedDateTime.parse("2019-12-31T23:50:00Z")));
}
testSPSTriggerProblemNextMonth
testSPSTriggerProblemNextYear
testSPSTriggerProblemNextMonthDayAst
testSPSTriggerProblemNextYearDayAst
I checked with v1.5 and v1.4.