How could I validate cron
expressions that are prepared for use of CronSequenceGenerator
?
I mean, I cannot wait until the cron executes automatically as I'm defining like monthly intervals.
Is the following correct? How can I be sure?
monthly at midnight: `0 0 0 1 * *`
monthly at 1 am: `0 0 1 1 * *`
weekly, on sunday at midnight: `0 0 0 * * SUN`
A question mark ( ? ) is allowed in the day-of-month and day-of-week fields. It is used to specify “no specific value,” which is useful when you need to specify something in one of these two fields, but not in the other.
The Spring's CronSequenceGenerator class has a method isValidExpression(String expression) which takes the cron expression and returns a boolean.
I guess if you are ok with quartz api then you should use org.quartz.CronExpression.isValidExpression(String s)
Api ref http://quartz-scheduler.org/api/2.2.0/org/quartz/CronExpression.html
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