Quartz error ? in the wrong place
'?' can only be specified for Day-of-Month -OR- Day-of-Week.
java.lang.RuntimeException: CronExpression '0 0 12 ? * ?' is invalid.
Caused by: java.text.ParseException: '?' can only be specified for Day-of-Month -OR- Day-of-Week.java.lang.RuntimeException: CronExpression '0 0 ? * * *' is invalid.
Caused by: java.text.ParseException: '?' can only be specified for Day-of-Month or Day-of-Week.Message produced by running the expression through org.quartz.CronExpression from Quartz 2.5.2.
What it means
Quartz has two messages about ?, which means “no specific value”. The one with “-OR-” in capitals means both day fields hold ?. One of them has to carry the schedule, so only one can be left open. The other means ? is in a field that isn’t a day field, such as the hour, where Quartz doesn’t allow it.
? is not a wildcard. For “every” in any field, use *.
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.
-
Use0 0 12 * * ?At 12:00.
Every day at noon:
*in day of month,?in day of week. -
Use0 0 * * * ?Every hour, on the hour.
Every hour on the hour:
*in the hour, and the?moved to day of week.
Questions
- What is the difference between
?and*in Quartz? *means every value.?means the field is deliberately left out, and it is only allowed in day of month and day of week. Quartz needs exactly one of those two to be?.- Can both day fields be
?? - No. That is what the message with “-OR-” is about. Give the field that carries the schedule a value or
*.
Other Quartz errors
- Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.Quartz: Both day fields are set
- Unexpected end of expression.Quartz: Five fields instead of six
- Day-of-Week values must be between 1 and 7Quartz: Sunday written as 0
- Hour values must be between 0 and 23Quartz: A value out of range
- Increment >= 60 : 90Quartz: A step longer than the field
- Unexpected character: @Quartz:
@dailyand other shortcuts