Get Next Execution Date from given date with Quartz Cron Expression

Viewed 700

I am trying to get Next Execution Date based on a Start Date and a Cron Expression using Quartz Cron Expression utility in Java. (org.quartz.CronExpression)

Following is my code to get next execution date

CronExpression exp = new CronExpression(cronExpression);
Date nextExecutionDate = exp.getNextValidTimeAfter(startDate);

Cron Expression is: 0 0 */1 ? * * (every 1 hour)

Input Start Date is: 2020-06-15T16:41:00.00

Current Output of Next Execution Date is: 2020-06-15T17:00:00.000

However, I expect the output of Next Execution Date as 2020-06-15T17:41:00.000

Kindly share some pointers to achieve the expected output. Do I need to alter the Cron Expression or do I need to add some time offset from start date? Kindly suggest.

1 Answers

You should alter the cron expression like

0 41 */1 ? * *
Related