Cron utils for parsing, validations and human readable descriptions as well as date/time interoperability.
jmrozanec on gh-pages
Update to new version (compare)
jmrozanec on master
Update README.md with new versi… (compare)
jmrozanec on 9.1.5
jmrozanec on 9.1.4
jmrozanec on master
Update pom.xml to 9.1.6-SNAPSHOT (compare)
jmrozanec on master
Update javadoc (compare)
jmrozanec on master
Update pom.xml version Update (compare)
jmrozanec on master
#470: ExecutionTime.isMatch() n… (compare)
jmrozanec on master
#472: Add spring to quartz cron… Merge branch 'master' of https:… (compare)
jmrozanec on master
ci: JDK 8, JDK 11, JDK 16 Merge pull request #473 from su… (compare)
jmrozanec on master
Create Issue470Test.java See I… Update Issue470Test.java Was u… Merge branch 'patch-1' of https… and 2 more (compare)
jmrozanec on master
Rework FieldExpressionVisitor s… Ignore failing test. Merge branch 'master' of https:… and 2 more (compare)
jmrozanec on master
Add clarification to javadoc Merge branch 'master' of https:… (compare)
jmrozanec on master
remove common-lang3 dependency add missing import Merge pull request #465 from da… (compare)
jmrozanec on master
PR for testing of issue 462 JU… Merge pull request #463 from no… (compare)
jmrozanec on gh-pages
Update version (compare)
jmrozanec on master
Update README.md (compare)
jmrozanec on master
Update README.md (compare)
jmrozanec on master
Update README.md (compare)
jmrozanec on master
Update README.md (compare)
@jmrozanec Thank you very much for your response! I am indeed using v7.0.4
My pom.xml includes:
<dependency>
<groupId>com.cronutils</groupId>
<artifactId>cron-utils</artifactId>
<version>7.0.4</version>
</dependency>
The code you can use to replicate the problem is as follows (sorry, I see I copied the schedule expression incorrectly in my previous message...):
String schedule = "0 0 * ? * SAT-SUN *";
CronParser parser = new CronParser(cronDefinition);
Cron quartzCron = parser.parse(schedule);
CronDescriptor descriptor = CronDescriptor.instance();
String description = descriptor.describe(quartzCron);
System.out.println(description);
ZonedDateTime time = ZonedDateTime.now();
ExecutionTime executionTime = ExecutionTime.forCron(quartzCron);
// Time from last execution to now
Duration timeFromLastExecution = executionTime.timeFromLastExecution(time).get();
System.out.println(timeFromLastExecution.toMinutes());
Hi, I'm trying to understand how to use the parser in order to compute next execution based on the last execution.
is this code should work?
ZonedDateTime lastExecution = ZonedDateTime.ofInstant(new Date(entity.getEndTime()).toInstant(), ZoneId.systemDefault());
executionTime.lastExecution(lastExecution);
ZonedDateTime now = ZonedDateTime.now();
final long millis = executionTime.timeToNextExecution(now).get().toMillis();