[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Cannot understand 'cronExpression.getNextValidTimeAfter(date)'  XML
Forum Index -> Quartz
Author Message
roise0r

neo

Joined: 04/24/2013 09:42:00
Messages: 2
Offline

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.
roise0r

neo

Joined: 04/24/2013 09:42:00
Messages: 2
Offline

Well, my cron expression is wrong for starters!!

How do I delete posts here?
gyan10

ophanim

Joined: 06/28/2011 23:15:25
Messages: 701
Offline

Its good to hear that you found your answer.
Thread closed.

Cheers!!

Gyan Awasthi
Terracotta -A Software AG company
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team