Open sunshine7690 opened 1 month ago
public static void main(String[] args) { CronDefinition definition = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ); CronParser parser = new CronParser(definition); Cron cron = parser.parse("/8 * ?"); ExecutionTime executionTime = ExecutionTime.forCron(cron); ZonedDateTime now = ZonedDateTime.of(2024, 9, 12, 10, 46, 57, 0, ZoneOffset.UTC); System.out.println("now "+now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); now = executionTime.nextExecution(now).get(); System.out.println(" nextExecution "+ now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); }
Run the code. result is: now 2024-09-12 10:46:57 nextExecution 2024-09-12 10:47:00
During cross-minute, the next execution time is incorrect.
public static void main(String[] args) { CronDefinition definition = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ); CronParser parser = new CronParser(definition); Cron cron = parser.parse("/8 * ?"); ExecutionTime executionTime = ExecutionTime.forCron(cron); ZonedDateTime now = ZonedDateTime.of(2024, 9, 12, 10, 46, 57, 0, ZoneOffset.UTC); System.out.println("now "+now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); now = executionTime.nextExecution(now).get(); System.out.println(" nextExecution "+ now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); }
Run the code. result is: now 2024-09-12 10:46:57 nextExecution 2024-09-12 10:47:00
During cross-minute, the next execution time is incorrect.