4

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.

Suman
  • 143
  • 1
  • 11

1 Answers1

2

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.

GolamMazid Sajib
  • 8,698
  • 6
  • 21
  • 39
  • Thanks for the answer. I actually thought of this, but I wanted quartz expression to do this. – Suman Aug 14 '18 at 04:52