My server runs on Europe/Rome timezone -and this one is the default tz on the server-, I need to schedule jobs according the user's timezone, so, if a user, living on Pacific/Honolulu timezone, schedules a CronTrigger that fires every day at 22:00pm for his region of the Earth I have found this solution:
CronTrigger trigger = newTrigger()
.withIdentity("name", "group")
.withSchedule(
cronSchedule("0 0 22 ? * *").inTimeZone(TimeZone.getTimeZone("Pacific/Honolulu"))
)
.startNow()
.build();
On my server this job starts at 09:00am of the "my" next day.
There are particular problems to be taken into consideration besides the fact to keep updated the timezone (i.e. Timezone Updater Tool) ?
If I want to define the .startAt() and .endAt() for the previous job, is this kind of date ok? A possible daylight saving time is safe using this procedure?
Calendar calTZStarts = new GregorianCalendar(TimeZone.getTimeZone("Pacific/Honolulu"));
calTZStarts.set(2013, Calendar.JANUARY, 10);
Calendar calTZEnds = new GregorianCalendar(TimeZone.getTimeZone("Pacific/Honolulu"));
calTZEnds.set(2013, Calendar.JANUARY, 30);
Calendar calStarts = Calendar.getInstance();
calStarts.set(Calendar.YEAR, calTZStarts.get(Calendar.YEAR));
calStarts.set(Calendar.MONTH, calTZStarts.get(Calendar.MONTH));
calStarts.set(Calendar.DAY_OF_MONTH, calTZStarts.get(Calendar.DAY_OF_MONTH));
calStarts.set(Calendar.HOUR_OF_DAY, calTZStarts.get(Calendar.HOUR_OF_DAY));
calStarts.set(Calendar.MINUTE, calTZStarts.get(Calendar.MINUTE));
calStarts.set(Calendar.SECOND, calTZStarts.get(Calendar.SECOND));
calStarts.set(Calendar.MILLISECOND, calTZStarts.get(Calendar.MILLISECOND));
Calendar calEnds = Calendar.getInstance();
calEnds.set(Calendar.YEAR, calTZEnds.get(Calendar.YEAR));
calEnds.set(Calendar.MONTH, calTZEnds.get(Calendar.MONTH));
calEnds.set(Calendar.DAY_OF_MONTH, calTZEnds.get(Calendar.DAY_OF_MONTH));
calEnds.set(Calendar.HOUR_OF_DAY, calTZEnds.get(Calendar.HOUR_OF_DAY));
calEnds.set(Calendar.MINUTE, calTZEnds.get(Calendar.MINUTE));
calEnds.set(Calendar.SECOND, calTZEnds.get(Calendar.SECOND));
calEnds.set(Calendar.MILLISECOND, calTZEnds.get(Calendar.MILLISECOND));
CronTrigger trigger = newTrigger()
.withIdentity("name", "group")
.withSchedule(
cronSchedule("0 0 22 ? * *").inTimeZone(TimeZone.getTimeZone("Pacific/Honolulu"))
)
.startAt(calStarts.getTime())
.endAt(calEnds.getTime())
.build();
or I have to set simply start and end using:
Calendar calTZStarts = new GregorianCalendar();
calTZStarts.set(2013, Calendar.JANUARY, 10, 0, 0, 0);
Calendar calTZEnds = new GregorianCalendar();
calTZEnds.set(2013, Calendar.JANUARY, 30, 0, 0, 0);
CronTrigger trigger = newTrigger()
.withIdentity("name", "group")
.withSchedule(
cronSchedule("0 0 22 ? * *").inTimeZone(TimeZone.getTimeZone("Pacific/Honolulu"))
)
.startAt(calTZStarts.getTime())
.endAt(calTZEnds.getTime())
.build();
Then the job starts/ends correctly in "Pacific/Honolulu" defined days?
Thanks in advance for every suggestion