1

I was using Simple schedulers and I had a problem that for example I had a job which was executing once in a day at 13:00 , but when daylight saving was emerging it was executed at 14:00, but I wanted it to be executed exactly at 13:00. I researched and saw that I could set timezone to cronScheduler and it should solve the problem, then I modified code and now I have

trigger = (CronTrigger) TriggerBuilder.newTrigger()
        .withIdentity(key, group)
        .startAt(startTime)
        .withSchedule(schedBuilder.withMisfireHandlingInstructionFireAndProceed()
                .inTimeZone(TimeZone.getTimeZone(timeZone)))
        .forJob(jobDetail.getKey().getName(), jobDetail.getKey().getGroup())
        .build();

where I am setting timezone for example Europe/Berlin and CronExpression something like this 0 0 13 * * ? * but when time changes due to daylight saving I am getting same behavior and trigger is exeuted at 14:00:00 instead of 13:00:00. Am I still missing something or what is the issue? What is the possible solution to fix this issue ? If this timezone of CronTrigger does not have any effect, what is the reason to have(set) it ?

I was expected something like this if I set Europe/Berlin timezone and 0 0 13 * * ? * expression it should be run exactly at 13:00:00 for Berlin time and same for any other timezones.

Gog1nA
  • 376
  • 1
  • 8
  • 30
  • So you want that in winter your job runs at 13:00+01:00 equal to 12:00 UTC, and in summer at 13:00+02:00 equal to 11:00 UTC? Asking without knowing your cron scheduler, just wanting to set things straight. (If I understand correctly, it’s the opposite of what I think @g00se assumed.) – Ole V.V. Jul 08 '21 at 18:49
  • 1
    @OleV.V. Yes that is what I want. If I set Berlin timezone to cron scheduler and set to execute at 13:00 I want it to be executed always at 13:00, no matter it is winter or summer time – Gog1nA Jul 08 '21 at 19:14
  • Always at the same time == no time zone – g00se Jul 08 '21 at 19:24
  • @g00se You and I seem to understand the question very differently. I understand always at the same wall-clock time in Europe/Berlin time zone, that is, time zone is an integrated part of the requirement. – Ole V.V. Jul 09 '21 at 05:31
  • 2
    @ole-v-v yes things like this are confusing. I can't imagine that Quartz have got their schedules for 'at time X' wrong. If you schedule for 'always at 13:00' then unless Quartz are buggy, it should always execute at 13:00 *irrespective of time of year*. The only way that could appear 'wrong' is if you observe the firing *from a different time zone*. That's the way I look at it. If it fires when a correct clock in Europe/Berlin tz reports a time other than 13:00, then there's a bug in Quartz imo. IS that what's happening two-rhombuses ? – g00se Jul 09 '21 at 10:11

0 Answers0