-
Notifications
You must be signed in to change notification settings - Fork 268
Closed
Description
It seems day of week is being incorrectly computed occasionally for Quartz cron expressions.
This works fine:
final CronType cronType = CronType.QUARTZ;
final CronParser quartzParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(cronType));
ExecutionTime executionTime = ExecutionTime.forCron(quartzParser.parse("0 * * ? * 1 *"));
DateTime nextTime = executionTime.nextExecution(DateTime.now());
assertNotNull(nextTime);
assertEquals(DateTimeConstants.SUNDAY, nextTime.getDayOfWeek());
But with value for Month:
final CronType cronType = CronType.QUARTZ;
final CronParser quartzParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(cronType));
ExecutionTime executionTime = ExecutionTime.forCron(quartzParser.parse("0 * * ? 5 1 *"));
DateTime nextTime = executionTime.nextExecution(DateTime.now());
assertNotNull(nextTime);
assertEquals(DateTimeConstants.SUNDAY, nextTime.getDayOfWeek());
Yields:
java.lang.AssertionError:
Expected :7
Actual :2
And with a value for Year:
final CronType cronType = CronType.QUARTZ;
final CronParser quartzParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(cronType));
ExecutionTime executionTime = ExecutionTime.forCron(quartzParser.parse("0 * * ? * 1 2099"));
DateTime nextTime = executionTime.nextExecution(DateTime.now());
assertNotNull(nextTime);
assertEquals(DateTimeConstants.SUNDAY, nextTime.getDayOfWeek());
Yields:
java.lang.AssertionError:
Expected :7
Actual :6
For the last assertion.
Reactions are currently unavailable