-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Bug for last day of month for a specific month. Like trigger on the last day of September:
Quartz version: 2.5.0
Cron expression: 0 15 23 L ? *
Failing months: 2, 4, 6, 9, 11
Working months: 1, 3, 5, 7, 8, 10, 12
Timezone: Africa/Johannesburg
Current date: July 9, 2025
Issue: nextFireTime is null for non-31-day months
Code:
try {
String[] months = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
for (String month : months) {
String cron = "0 15 23 28-31 " + month + " ? *";
System.out.println("Testing cron: " + cron);
CronExpression cronExpression = new CronExpression(cron);
cronExpression.setTimeZone(TimeZone.getTimeZone("Africa/Johannesburg"));
Date currentDate = new Date(); // July 9, 2025, 12:13 PM SAST
Date nextFireTime = cronExpression.getNextValidTimeAfter(currentDate);
System.out.println("Next fire time for month " + month + ": " + nextFireTime);
}
} catch (Exception e) {
System.err.println("Error parsing cron expression: " + e.getMessage());
}