ITrigger cronTrigger = TriggerBuilder.Create()
.WithIdentity("trigger1", "group1")
.WithCronSchedule(0 0/1 * 1/1 * ? *)
.Build();
This code sets the time to run an hour before I want it to, so rather than running at 1:40 it runs at 12:40. Can I set the timezone of Itrigger to work for uk time ?
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger3", "group1")
.WithCronSchedule(
"Your CRON Expression comes here",
x => x.InTimeZone(TimeZoneInfo.FindSystemTimeZoneById("Your Time Zone Id comes here"))
)
.ForJob("GUID / any unique combination ID comes here ")
.Build()
Maybe a little cleaner:
ITrigger trigger = TriggerBuilder.Create()
.StartNow()
.WithCronSchedule("0 27 15 ? * MON-FRI *", x => x.InTimeZone(TimeZoneInfo.Utc))
.Build();
There should be a TimeZone option when creating your trigger. Something like this:
.inTimeZone(TimeZone.CurrentTimeZone);
The above will take the server's current timezone. If not a UK based server, this should work.
TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
Here is the link: http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With