Can I use Quartz Scheduler library to create schedule with following settings?:
- Starting from Dec, 30, 2014
- Execute each 30th day
- Every 2nd month consequently
- If month doesn't have 30th day, action should occur on the last day of month.
So, the resulting schedule will be:
- Dec 30, 2014
- Feb 28, 2015
- Apr 30, 2015
- ... and so on
From what I've learned:
- CronTrigger doesn't allow to do so (it could be set up only to be triggered on specific months and not on intervals),
CalendarIntervalTrigger will skip months that don't have 30th day (trigger created by following code)
try { SchedulerFactory schedulerFactory = new StdSchedulerFactory(); Scheduler scheduler = schedulerFactory.getScheduler(); scheduler.start(); JobDetail jobDetail = JobBuilder.newJob(HelloJob.class) .withIdentity("HelloJob_CalendarIntervaled", "calendarIntervaled") .build(); Calendar decemberThirty = Calendar.getInstance(); decemberThirty.set(Calendar.YEAR, 2014); decemberThirty.set(Calendar.MONTH, Calendar.DECEMBER); decemberThirty.set(Calendar.DAY_OF_MONTH, 30); CalendarIntervalTrigger calendarIntervalTrigger = newTrigger() .withIdentity("calendarIntervalTrigger", "calendarIntervaled") .withSchedule(CalendarIntervalScheduleBuilder.calendarIntervalSchedule() .withIntervalInMonths(2)) .startAt(decemberThirty.getTime()) .forJob(jobDetail) .build(); scheduler.scheduleJob(jobDetail, calendarIntervalTrigger); System.out.println(calendarIntervalTrigger.getNextFireTime()); } catch (SchedulerException e) { e.printStackTrace(); }
If no, are there any alternatives (it should work on JBoss eap 6.2.0)?