开发者

Scheduling tasks on London time while system time is NY

Our system is configured with US/Eastern time and we have some scheduled tasks which must occur at specific Europe/London times. How can we do this and make sure our tasks fire correctly when daylight time changes take effect?

We use Quartz for scheduling. Currently we schedule tasks using SimpleTrigger, and not CronTrigger. The docs indicate that CronTrigger should work - but I think this assumes the sched开发者_JAVA技巧uled time and the system time are on the same time zone.


CronTrigger would indeed serve your purpose better, as you can use its setTimeZone method to define which timezone will be used when resolving the trigger's CronExpression. And no, the scheduled time and system time do not need to be on the same timezone. So, it should certainly work. (Of course, pay attention to the notes about daylight savings and crontriggers in the documentation you linked to.)


CronTrigger should be fine so long as you build it using the right time zone - which you can ensure with CronScheduleBuilder.inTimeZone. At least that's my interpretation of the docs...


You can also do it with SimpleTrigger, but you have to take care in constructing the date to use as the trigger's startTime property (build that date in the desired timezone).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜