问题
How can i generate cron expression for every month 2nd/4th of monday/friday in quartz.Please help me
回答1:
You will need to create two triggers for the job.
The first trigger for the 2nd Monday:
0 0 12 ? 1/1 MON#2 *
And the second trigger for the 4th Friday:
0 0 12 ? 1/1 FRI#4 *
回答2:
According to the docs, you can specify (e.g.) the 2nd Monday of the month by putting MON#2
or 1#2
in the day-of-week field.
The '#' character is allowed for the day-of-week field. This character is used to specify "the nth" XXX day of the month.
But composing these like MON#2,FRI#4
in a single cron expression is specifically prohibited, so you need multiple CronTrigger
s.
来源:https://stackoverflow.com/questions/16935701/generate-quartz-cron-expression-every-2nd-monday-friday