Cron Atlas

Quartz error Sunday written as 0

Day-of-Week values must be between 1 and 7

java.lang.RuntimeException: CronExpression '0 0 9 ? * 0' is invalid.
Caused by: java.text.ParseException: Day-of-Week values must be between 1 and 7

Message produced by running the expression through org.quartz.CronExpression from Quartz 2.5.2.

What it means

Quartz numbers the days of the week from 1 to 7, with 1 = Sunday and 7 = Saturday. Unix cron, Kubernetes, GitHub Actions and Azure use 0 for Sunday, so a 0 copied from one of those is out of range here.

The quieter problem is the expressions that don’t fail. 1-5, which is Monday to Friday in Unix cron, is valid in Quartz and means Sunday to Thursday. Day names (SUN to SAT) mean the same thing everywhere, so they are the safer choice.

Rejected expressions and their fixes

Each expression opens in the tester. The message under a rejected one is what Quartz 2.5.2 printed for it.

  1. Rejected0 0 9 ? * 0Day-of-Week values must be between 1 and 7
    Use
    0 0 9 ? * SUNAt 09:00, on Sundays.

    Sundays at 09:00. 1 works too.

  2. Rejected0 0 9 ? * 0,6Day-of-Week values must be between 1 and 7
    Use
    0 0 9 ? * SAT,SUNAt 09:00, at weekends.

    Weekends at 09:00. In Quartz numbers that is 1,7.

  3. Rejected0 0 9 ? * 0-4Day-of-Week values must be between 1 and 7
    Use
    0 0 9 ? * SUN-THUAt 09:00, on Sunday through Thursday.

    Sunday to Thursday, written with names.

Questions

Is Sunday 0, 1 or 7 in Quartz?
Sunday is 1 and Saturday is 7, and 0 is not allowed. In Unix cron Sunday is 0, and most crons accept 7 too. EventBridge numbers days the way Quartz does.
Why does my weekday schedule run on Sunday?
Probably 1-5 was copied from Unix cron. In Quartz that is Sunday to Thursday. Use MON-FRI or 2-6.

Other Quartz errors

Reference