javawindowscronquartz-schedulercrontrigger

Cron expression for biweekly scheduler job on Monday in Windows 10 using Java


I have created a scheduler with two triggers to implement a biweekly scheduler Java program on Windows 10 using Cron expression. The two jobs are executed individually one each on alternate Monday of every month at 2pm, so maybe on even alternates or odd alternates. The current Cron expressions in use are as follows -

"0 0 14 ? * MON#1"
"0 0 14 ? * MON#3"

I want to implement both these jobs with a single trigger and thus a single Cron expression, but not able to club these two Cron expressions. Need help!


Solution

  • Quartz cron triggers do not support multiple "Nth" days.

    However, if you do not mind, you can use a CalendarIntervalTrigger that is more suitable for this type of a schedule. The following screenshot (from QuartzDesk GUI) shows you a CalendarIntervalTrigger with settings that cover your use-case.

    Biweekly CalendarIntervalTrigger Example