I need to set a quartz trigger for a job that includes a timezone. E.g. I need to set it for 27 August 2012 at 15:00 Europe/Amsterdam timezone. My server works on UTC.
I believe a SimpleTriggeris what I need, but I do not know how to set a timezone for it.
Any idea?
SimpleTrigger's fire time is based on the configured start time.
The start time is specified as a java.util.Date, which is really just time specified in milliseconds since Jan 1, 1970 00:00:00.000 GMT.
If, at Oct 23, 2010 8:13:45 EST your code executes new Date(), and sets the result as the start time, Quartz will store as the start time the value in milliseconds (1287839625000), and then the trigger will fire at Oct 23, 2010 8:13:45 EST regardless of which timezone the scheduler is running in.
If you use java.util.Calendar to define a date and time in a particular time zone, and then convert that to a Date, it will work exactly the same: If you have specified Oct 23, 2010 8:13:45 and the Calendar's time zone is EST then the resulting milliseconds value will again be 1287839625000. But if the timezone was PST (but the date time the same) the milliseconds value would be 1287850425000 (3 hours later).
Just make sure the system clock where Quartz is running has been correctly set and is maintained as UTC by the operating system.
I had the same requirement.I was able to achieve this using following way.
utcTime =userTimetoUTCTime("09/28/2017 12:00:00 AM")
Re convert UTC to server time zone and set it to simple trigger
utcTimetoUserTime(utcTime)
public static String userTimetoUTCTime(String userTime) {
public static Date utcTimetoUserTime(String utcTime) { return new DateTime(utcTime).toDate(); }
Note : Can set time zone in CronTrigger but not in SimpleTrigger