I have this:
Code:
CronExpression cronExpression = new CronExpression(cronString);
Date date = new Date();
Date nextValidTime1 = cronExpression.getNextValidTimeAfter(date);
Date nextValidTime2 = cronExpression.getNextValidTimeAfter(nextValidTime1);
Date nextValidTime3 = cronExpression.getNextValidTimeAfter(nextValidTime2);
nextValidTime1 does actually have the correct next valid time it should fire.
However, nextValidTime2 and nextValidTime3 have the same time as nextValidTime1 +1 second.
example:
if my cronString is "* * * 13 * ?", and right now is April 24th, 2013, 09:50:03 then:
nextValidTime1 = May 13th, 2013 00:00:00 (correct!)
nextValidTime2 = May 13th, 2013 00:00:01 (incorrect! It should be June 13th 2013, 00:00:00)
nextValidTime3 = May 13th, 2013 00:00:02 (incorrect! It should be July 13th 2013, 00:00:00)
===============================================================
What's interesting is that if i do this:
Code:
CronExpression cronExpression = new CronExpression(cronString);
Date date = new Date();
Date nextValidTime1 = cronExpression.getNextValidTimeAfter(date);
Date nextValidTime2 = cronExpression.getNextValidTimeAfter(new Date(nextValidTime1.getTime() + 172800000));
Date nextValidTime3 = cronExpression.getNextValidTimeAfter(new Date(nextValidTime2.getTime() + 172800000));
Then it does work.