Viswanathan S
Viswanathan S

Reputation: 13

Spring Cron expression

I need cron expression for triggering mail every 10th. but is that 10th is a weekend(saturday or sunday) then it has to be triggered two days before(if 10th is sat, then on thursday, and if 10th is sunday, then on friday)

Kindly help. This is my expression (0 0 12 10W 1/1 ? *). It checks for weekend and fires one day before. How to fire it two working days before

Upvotes: 1

Views: 492

Answers (2)

Amanuel Nega
Amanuel Nega

Reputation: 1977

How about two expressions? You could have 0 0 0 10 * MON-FRI which fires on 10th when it is workday and 0 0 0 8 * THU-FRI that fires when the weekend is 10th. That makes Thursday and Friday be on the 8th.

I hope this helps.

Upvotes: 0

Nikolay Rusev
Nikolay Rusev

Reputation: 4230

I think that in your case this cannot be done with cron expression. Just do simple cron expression which will run every day and should check if the date is 10th of the month and do all needed checks manually.

Upvotes: 1

Related Questions