Job execution every n weeks on weekdays a and b at x o'clock in Quartz
to run job on monday and tuesday at 10am, we need to identify the latest date of monday and tuesday first. and then use those date as startdate at CalendarIntervalTrigger.
identify the date of latest/next monday and tuesday from today date. the code can be found here.then applied the date on Quartz calendarIntervalSchedule.
//dd.M.yyyy hh:mm:ss a
//Monday
String getMondayDate = "23 JUNE 2014 10:0:0 am"
String MONDAY = getMondayDate;
Date startDate = new SimpleDateFormat("dd.M.yyyy hh:mm:ss a").parse(MONDAY);
Trigger trigger = newTrigger()
.withIdentity("mondayTrigger", "group1")
.startAt(startDate) //put retrieved monday date here
.withSchedule(calendarIntervalSchedule()
.withIntervalInWeeks(2)) // interval is set in calendar weeks
.build();
//Tuesday
String getTuedayDate = "24 JUNE 2014 10:0:0 am"
String TUESDAY = getTuesdayDate;
Date startDate = new SimpleDateFormat("dd.M.yyyy hh:mm:ss a").parse(TUESDAY);
Trigger trigger = newTrigger()
.withIdentity("mondayTrigger", "group1")
.startAt(startDate) //put retrieved monday date here
.withSchedule(calendarIntervalSchedule()
.withIntervalInWeeks(2)) // interval is set in calendar weeks
.build();