BackendBench
Coffee

Home โ€บ Cron errors โ€บ Spring

Spring ยท error

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

wrong
0 0 12 * * ? 2030

Our parser says: Spring @Scheduled (6-field) needs 6 fields, but you gave 7

fixed
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

  1. Remove the year field.
  2. If you need a one-off date, schedule it with a TaskScheduler and a Date or Instant instead.
  3. 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 * * ?:

SystemExpression
Quartz0 0 12 * * ?
Crontab0 12 * * *
Kubernetes0 12 * * *
AWS EventBridge0 12 * * ? *
Jenkins0 12 * * *
GitHub Actions0 12 * * *
node-cron0 12 * * *
Apache Airflow0 12 * * *
Azure Functions0 0 12 * * *
Google Cloud Scheduler0 12 * * *

Try it yourself

The tester below starts with the fixed expression. Change it and watch the schedule update.

Your week at a glance
fewer more runs

Upcoming runs

#LocalUTCFrom 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.

More tools you might need