I am using quartz expressions to create a trigger that should execute only on Mondays and the day of month
should not be 1
.
I already know that 0 5 0 2-31 * MON
expression doesn't work because Specifying both a day-of-week and a day-of-month parameter is not implemented
. Is there any workaround for this issue? How can I achieve this?
To summarize, if 1st day of month is Monday, the above expression should not be executed but for other Mondays of the month, it should be executed.
As support for specifying both a day-of-week AND a day-of-month parameter is not implemented, You can try with this:
@Scheduled(cron = "0 5 0 ? * MON")
private void doTask(){
if(LocalDate.now().getDayOfMonth() != 1){
//your code here
}
}
You can also check and generate corn for quartz here.
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