viewer.csslab.dev

Spring Cron Expression Reader

Read a Spring @Scheduled expression back in words — six fields, seconds first.

What does Spring's @Scheduled expect?

Spring's @Scheduled takes six fields: second, minute, hour, day-of-month, month, day-of-week. The leading seconds field is the difference that catches people — a five-field crontab line pasted into @Scheduled either fails to start the application or, worse, schedules something entirely different from what was intended.

Spring's parser is its own, not Quartz's and not crontab's. It accepts ? as a synonym for * in the day fields rather than requiring it, supports L and # in day-of-week, and adds macros such as @daily and @hourly. This page reads the expression back in words so the schedule can be checked before it ships.

The pattern is a list of six single space-separated fields: representing second, minute, hour, day, month, weekday.
Spring Framework — CronExpression

Features

Six fields, labelled
The breakdown names each field with seconds first, so a crontab line pasted by mistake shows up immediately as one field short.
Reads Spring's day rules
Spring treats ? as equivalent to * rather than requiring it in exactly one day field, which is where expressions copied from Quartz documentation go wrong.
Plain-language output
The expression is rendered as a sentence, so reviewing a scheduled job does not depend on anyone remembering field order.
Run times only when they are trustworthy
Expressions using L or # do not get a next-run list — the available parsers read those differently from Spring, and a wrong time here would be worse than none.

How to use

  1. 1

    Copy the expression from the annotation

    Take the string inside @Scheduled(cron = "...").

  2. 2

    Paste it here

    Six fields with seconds first. Macros such as @daily are also read.

  3. 3

    Read the sentence and the fields

    Confirm the schedule says what the ticket asked for, and that no field is in the wrong position.

  4. 4

    Remember the time zone

    @Scheduled runs in the JVM's default zone unless the annotation sets one. Containers commonly default to UTC.

Frequently asked questions

Why does my crontab expression fail in @Scheduled?

Spring expects six fields with seconds first; crontab has five. A five-field expression either fails validation at startup or is read with every field shifted by one, which schedules something quite different.

What does ? mean in Spring?

The same as *. Unlike Quartz, Spring does not require ? in exactly one day field — it accepts it as a synonym. Expressions copied from Quartz documentation therefore usually work, but the reverse is not true.

Can I use @daily or @hourly?

Yes. Spring supports macros including @yearly, @monthly, @weekly, @daily and @hourly, which expand to the equivalent six-field expressions. @reboot has no equivalent, because it is triggered by startup rather than by time.

Which time zone does @Scheduled use?

The JVM default unless the annotation sets zone. Containers commonly run in UTC while the developer is thinking in local time, which is a frequent source of jobs that fire nine hours away from where they were expected.

Does Spring support the seventh year field?

No. Quartz allows an optional trailing year field; Spring's parser does not, so a seven-field Quartz expression will not validate.

If you hit this

Specifications this follows

Related tools