Skip to content

Simplify programmatic scheduling of cron tasks with time zone#36556

Open
vpavic wants to merge 1 commit into
spring-projects:mainfrom
vpavic:scheduling-improvements
Open

Simplify programmatic scheduling of cron tasks with time zone#36556
vpavic wants to merge 1 commit into
spring-projects:mainfrom
vpavic:scheduling-improvements

Conversation

@vpavic

@vpavic vpavic commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

This commit adds overloaded addCronTask to ScheduledTaskRegistrar that allows simpler scheduling of cron tasks with non-default time zone.


In practical terms, currently we have to do this:

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.addCronTask(new CronTask(() -> {}, new CronTrigger("* * * * * ?", ZoneId.of("Europe/London"))));
}

While the changes from this PR allow us to reduce it to:

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.addCronTask(() -> {}, "* * * * * ?", ZoneId.of("Europe/London"));
}

This commit adds overloaded `addCronTask` to `ScheduledTaskRegistrar`
that allows simpler scheduling of cron tasks with non-default time zone.

Signed-off-by: Vedran Pavic <vedran@vedranpavic.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 27, 2026
@sbrannen sbrannen self-assigned this Jun 25, 2026
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 25, 2026
@sbrannen sbrannen added this to the 7.1.0-M1 milestone Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants