Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Quartz - CronTrigger - Problem when executing a job monthly

807588Nov 3 2008 — edited Jan 20 2009
Hi everyone:

I've been looking around and trying to do it with some methods but I can't find the solution. The problem is: I have to give the user the option of selecting when execute the job. One option is executing it monthly and they can set the day of the month. Here is the problem, if they select a date after 28 I get a problem when february comes. What I want to do is that if they select the date to execute the job in the 31th for example, in the months that don't have 31 days, the job would be executed on the 30th of those months. That's no problem because I can set there a conditional clause and if date==31 set in the cron expression 'L' for the day of the month (execute the last day of the month), but it does not work for february, 'cause if they select the day 29th, it won't be executed in february.

I've guessed that the only solution for this is editing the cron once we are in the execution of the job, and if day of execution is greater than 28 and the current month is january, set the nextfiredtime to the last day of february but it doesn't work with

job.getTrigger().getNextFireTime().setTime(xxx);

or

job.getNextFireTime().setTime(xxx)

Do you know anything I can do to manage this problem? I would appreciate it very much
Thank you very muc for your attention
Kind regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2009
Added on Nov 3 2008
1 comment
549 views