javatimezonequartz-schedulercrontrigger

Java Quartz Scheduler - update trigger timezone


I have existing CronTrigger and i want to update only the timeZone. How can i do it?

 CronTrigger trigger = (CronTrigger) scheduler.getTrigger(key);
 // trigger.setTimeZone("..");-- not available

Solution

  • Well, i think i found the answer. It works but i'm not sure this is the best way. The idea is to edit the timezone using CronTriggerImpl and than reschedule the job with updated trigger.

    CronTrigger trigger = (CronTrigger) scheduler.getTrigger(key);
    ((CronTriggerImpl) trigger).setTimeZone(TimeZone.getTimeZone(timeZone));
    scheduler.rescheduleJob(trigger.getKey(), trigger);