Spring调度任务在多个时区运行的日期时间

huangapple go评论72阅读模式
英文:

Spring Scheduler task run with multiple timezones dateTime

问题

我有多个客户使用不同的时区,而应用程序使用UTC时间。所以,通常我实现了以下计划任务:

@Scheduled(cron = "0 10 0 * * ?") // 此调度程序将每天在00:10 AM运行并发送通知。

但问题是它以UTC时间的12:10 AM运行;但根据客户的时区不同,运行时间可能会有所不同。

例如,在IST时区,UTC 00:10 AM相当于5:40 AM,因此印度客户将在IST的05:40 AM而不是IST的00:10 AM收到通知。

要求:我需要在每个客户的时区中在00:10 AM运行任务(调度程序),而不是在应用程序的UTC时区中运行。

英文:

I have multiple timeZone customers wise and Application works with UTC.So, Normally I implemented

@Scheduled(cron = "0 10 0 * * ?") // This scheduler will run at 00:10 AM daily And Send Notification.

But the problem is it runs on UTC time 12:10 AM; However, it may differ based on customer TimeZone

eg. UTC 00:10 AM In IST it's 5:40 AM so India's customer will get a notification at 05:40 AM instead of 00:10 AM in IST.

Require: I need to run a task(scheduler) at 00:10 AM in each customer time zone Not in Application TimeZone(UTC).

答案1

得分: 1

user.timezone Java system property might help

英文:

user.timezone Java system property might help

huangapple
  • 本文由 发表于 2020年8月13日 20:37:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63395311.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定