Skip to content

Simplify programmatic scheduling of cron tasks with time zone#36556

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

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

Conversation

@vpavic
Copy link
Copy Markdown
Contributor

@vpavic vpavic commented Mar 27, 2026

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants