Spring Cron

Spring Framework's `@Scheduled` cron — 6 fields (with seconds), no `L`/`W`/`#`, and 0-indexed day-of-week like Unix.

Overview

Spring's `CronExpression` parser (used by `@Scheduled(cron = …)`) is a Quartz-inspired 6-field format, but it intentionally drops the year field and the `L`, `W`, `#`, and `?` tokens that Quartz supports.

Crucially, Spring uses Unix-style day-of-week numbering (0=Sun … 6=Sat) — not Quartz's 1=Sun convention. If you're porting Quartz expressions to Spring, the DOW values almost always need adjusting.

Field Structure

Field Order6 fields: second minute hour day-of-month month day-of-week
Day-of-Week0 or 7 = Sunday, 1=Monday, …, 6=Saturday.

Special Characters

TokenMeaning
*Any value.
,List.
-Range.
/Step.

Aliases

  • `@yearly`, `@annually`, `@monthly`, `@weekly`, `@daily`, `@midnight`, `@hourly` (since Spring 5.3).

Comparison vs. Unix Cron

FeatureSpring CronUnix Cron
Field count6 (seconds first)5
Seconds fieldYesNo
Step syntaxYesLimited
Named months/daysYesNo
AliasesYes (Spring 5.3+)No
DOW numbering0=Sun … 6=Sat (like Unix)0=Sun … 6=Sat
`L`, `W`, `#`No (not supported)No
Year fieldNoNo

Examples

0 0 12 * * *Every day at 12:00:00.Try it →
0 */5 * * * *Every 5 minutes.Try it →
0 0 0 * * MON-FRIMidnight on weekdays.Try it →
0 0 9 1 * *9 AM on the 1st of every month.Try it →
0 30 8 * * 108:30 every Monday.Try it →
@hourlyTop of every hour (Spring 5.3+).

Gotchas & Pitfalls

  • Don't reuse Quartz expressions verbatim — DOW numbering differs (Quartz Sun=1, Spring Sun=0) and Spring rejects `?`, `L`, `W`, `#`.
  • Pre-Spring-5.3 expressions used a different parser; check the migration notes if you're upgrading from Spring Boot 2.x.
  • Spring's `@Scheduled(zone = …)` lets you pin a timezone per task — without it the JVM default applies.

References

Free cron syntax cheat sheet

© 2026 Abel Solutions LLC. All rights reserved. · More from Abel Solutions: RegexPro — test and debug regular expressions