Home โบ Cron errors โบ Spring
Spring error: found 7 fields (a Quartz expression)
java.lang.IllegalArgumentException: Cron expression must consist of 6 fields (found 7) in "0 0 12 * * ? 2030"Why this happens
The seventh field (year) exists only in Quartz. Spring stops at six fields.
Wrong and right
0 0 12 * * ? 2030Our parser says: Spring @Scheduled (6-field) needs 6 fields, but you gave 7
0 0 12 * * ?At 12:00 UTC. First runs after 1 Jan 2027 (UTC): Fri 01 Jan, 12:00, Sat 02 Jan, 12:00, Sun 03 Jan, 12:00, Mon 04 Jan, 12:00, Tue 05 Jan, 12:00
How to fix it
- Remove the year field.
- If you need a one-off date, schedule it with a TaskScheduler and a Date or Instant instead.
- Also check the ? characters: Spring accepts them, but if you copied from Quartz make sure the weekday numbers still mean what you expect (Spring Sunday is 0, Quartz Sunday is 1).
The Spring format at a glance
Fields in order: second (0-59), minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-7, 0 and 7 = Sunday).
Spring evaluates in the server time zone by default. Add zone = "UTC" (or any ZoneId) to @Scheduled to make it explicit.
The fixed schedule in other systems
If you are moving this schedule to another scheduler, these are the equivalents of 0 0 12 * * ?:
| System | Expression |
|---|---|
| Quartz | 0 0 12 * * ? |
| Crontab | 0 12 * * * |
| Kubernetes | 0 12 * * * |
| AWS EventBridge | 0 12 * * ? * |
| Jenkins | 0 12 * * * |
| GitHub Actions | 0 12 * * * |
| node-cron | 0 12 * * * |
| Apache Airflow | 0 12 * * * |
| Azure Functions | 0 0 12 * * * |
| Google Cloud Scheduler | 0 12 * * * |
Try it yourself
The tester below starts with the fixed expression. Change it and watch the schedule update.
Your week at a glance
Upcoming runs
| # | Local | UTC | From now |
|---|
Copy-ready code
Frequently asked questions
Can Spring run a job in one specific year?
Not through @Scheduled cron. Use a programmatic schedule.
More Spring fixes
See the full Spring cron builder or convert between formats.