Skip to content

Add time zone support to the @Scheduled annotation for cron jobs [SPR-10456] #15089

@spring-projects-issues

Description

@spring-projects-issues

Mattias Severson opened SPR-10456 and commented

I suggest that a new timezone element is added to the @Scheduled annotation that can be used in conjunction with the cron element.

Background:

Currently, it is not possible to specify a time zone to the cron element of the @Scheduled annotation. As a consequence, the CronSequenceGenerator constructor calls TimeZone.getDefault() internally, which causes the cron job to depend on the local time of the server that the app has been deployed on.

The idea is that the new timezone element should be converted into a TimeZone instance, that can be used to when calling the appropriate CronTrigger constructor, which in turn calls the appropriate constructor of the CronSequenceGenerator.

For the record, the standard the CronExpression class in the Quartz Scheduler project has a setTimeZone() method that solves this use case.


Affects: 3.2.2

Referenced from: commits 0c00b0d

1 votes, 4 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions