The text on the website says the cows are milked at 4am.
However, the cron expressions in the ScheduledJobs class are, by default, expressed in Zulu time (i.e. Coordinated Universal Time, aka Greenwich Mean Time).
We would prefer that to be in local time.
Expected Behavior
It should be 4am local time
Current / Observed Behavior
It isn't
Steps to Reproduce
Look at the logs to see when the job actually ran.
Implementation Notes
As explained here it's possible to include a timezone in the @Scheduled annotations. The example given is:
It's ok to hard code it for now. If we ever need to support another timezone, we can make this a configuration variable like the cron expressions are.
To test
Check the logs for the scheduled jobs and see when they run. If necessary, you can override the default schedule with configuration variables. See the src/main/resources/application.properties file where you'll find expressions like these:
Summary
The text on the website says the cows are milked at 4am.
However, the cron expressions in the
ScheduledJobs
class are, by default, expressed in Zulu time (i.e. Coordinated Universal Time, aka Greenwich Mean Time).We would prefer that to be in local time.
Expected Behavior
It should be 4am local time
Current / Observed Behavior
It isn't
Steps to Reproduce
Look at the logs to see when the job actually ran.
Implementation Notes
As explained here it's possible to include a timezone in the
@Scheduled
annotations. The example given is:The zone we want is this one:
America/Los_Angeles
http://www.timezoneconverter.com/cgi-bin/zoneinfo?tz=America/Los_Angeles
It's ok to hard code it for now. If we ever need to support another timezone, we can make this a configuration variable like the cron expressions are.
To test
Check the logs for the scheduled jobs and see when they run. If necessary, you can override the default schedule with configuration variables. See the
src/main/resources/application.properties
file where you'll find expressions like these:and the corresponding entries in
src/main/resources/application-development.properties
For an explanation of the syntax
0 */13 * * * *
or0 0 0,12 * * *
see https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions