Quartz to observe daylight saving time changes

Hello,
I need some advice on how to handle DST quartz jobs scheduling.
I have many quartz jobs running the morning reports and emailing them to customers. They are scheduled with quartz cron expressions, UTC time.

  • how can I make such jobs to observe the DST automatically as its not practical to reschedule many jobs?
    → seems its possible with quartz, to schedule programatically
CronScheduleBuilder.cronSchedule("0 0 12 * * ?") // Schedule for 12 PM daily
                  .inTimeZone(TimeZone.getTimeZone("America/New_York")); // Specify the time zone

however Jmix addon UI does not have that option, and I would like users to be able to handle the scheduling from the UI

  • Would it be OK to extend the addon UI and code to accommodate this?
  • Is anyone using quartz DST jobs? What is your experience

→ another approach I can think of is to reschedule QuartzScheduler.rescheduleJob at the DST night, go through all the jobs and change the cron expression, which approach is better?

Kind regards,
Mladen

Hi,

Is anyone using quartz DST jobs? What is your experience

I don’t remember any requests about it.

Would it be OK to extend the addon UI and code to accommodate this?

To provide an option to configure timezone from addon UI you will need to extend UI (trigger details), model (trigger) and QuartzService to apply specified timezone to created Cron Schedule.

Created a ticket to implement this in product (Support timezone in Quartz trigger configuration · Issue #4712 · jmix-framework/jmix · GitHub).

But it will affect only new triggers - already scheduled ones should be resheduled.

If you implement extension mentioned above you can reshedule them manually once.

Another approach you mentioned (with bulk reschedule) also should work.
Go through all jobs, get their triggers, create similar trigger but with new schedule and reschedule via QuartzScheduler.rescheduleJob. Then call it from somethere.

If during this process you adjust the cron expression to imitate DST shift - it should work, but looks a little clunky.
If you adjust the timezone - it looks more correct in general, but it will basically require the extension mentioned above. Because any further changes in trigger/job will lead to recreate and reschedule it and it will be done according to QuartzService behavior. And if it doesn’t know about timezone - it will recreate trigger the “old way” (so you will have to perform resheduling again).

It’s hard to say what approach is better.
If you need more control, possibility to specify different timezones, cleaner solution - extension looks better.
If just adjusting the cron expression is ok for you - maybe just rescheduling will be better. It’s simplier, but can be confusing during further modification.

Regards,
Ivan

Thank you Ivan for the help.

Indeed, the extension seems the best solution. I will wait for some time to see when this will be implemented before doing it myself, because it’s always best to use the platform …

Kind regards,
Mladen