Quartz 2.x documentation says
So cron expressions can be as simple as this: * * * * ? * or more complex, like this: 0/5 14,18,3-39,52 * ? JAN,MAR,SEP MON-FRI 2002-2010
But if I try
System.out.println(org.quartz.CronExpression.isValidExpression("* * * * ? * *"));
It says
false
Why?
Javadoc for the isValidExpression is http://quartz-scheduler.org/api/2.2.1/org/quartz/CronExpression.html
Ps. this question is NOT a duplicate of Verifying a cron expression is valid in Java
The linked JavaDoc mentions this structure for cron expressions:
Field Name Allowed Values Allowed Special Characters
Seconds 0-59 , - * /
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day-of-month 1-31 , - * ? / L W
Month 1-12 or JAN-DEC , - * /
Day-of-Week 1-7 or SUN-SAT , - * ? / L #
Year (Optional) empty, 1970-2199 , - * /
Your cron expression is "* * * * ? * *"
with a ?
on the 5th position for Month
. As you can see, this character is not allowed there.
The JavaDoc you mentioned states that the ?
character is allowed only for day-of-month and day-of-week fields. You are using it in Month field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With