API Usage
CronMaker api version was developed to offer functionality similar to CronMaker Web Site.
This document describes the api by giving examples with screenshots of the web site.
Minutes panel
The code to get a cron expression for events occurring every 2 minutes;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
MinuteBasedExpression exp = builder.makeMinuteBasedExpression();
exp.setInterval(MinuteInterval.Min2);
Get corresponding cron expression;
Returns next 5 dates occurring at the times set by cron expression
builder.calcNextDates(new Date(), 5);
Hourly panel
The code to get a cron expression for events occurring every hours;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeHourBasedExpression().setInterval(HourInterval.Hour1);
builder.getCronExpressionGenerator().getCronExpression();
builder.calcNextDates(new Date(), 3);
To run at specific time;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeHourBasedExpression().setTime(14, 4);
builder.getCronExpressionGenerator().getCronExpression();
builder.calcNextDates(new Date(), 3);
Daily panel
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeDayBasedExpression().setForEveryDay();
builder.getCronExpressionGenerator().getCronExpression();
builder.calcNextDates(new Date(), 10);
To run at weekdays;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeDayBasedExpression().setEveryWeekDay();
builder.getCronExpressionGenerator().getCronExpression();
builder.calcNextDates(new Date(), 10);
Weekly panel
To generate cron expression denoting every Tuesday and Sunday;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeWeekBasedExpression().setDays(Day.Tuesday, Day.Sunday);
builder.getCronExpressionGenerator().getCronExpression();
builder.calcNextDates(new Date(), 5);
Monthly panel
Generates cron expression to be run at the 21th day of every 3 months
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeMonthBasedExpression().setDayOfMonthInterval(21, MonthInterval.Month3);
builder.getCronExpressionGenerator().getCronExpression();
Date nextDate = builder.calcNextDates(new Date(), 1).get(0);
Generates expression for representing second wednesday of every month;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeMonthBasedExpression().setDayRankOfMonthInterval(Rank.Second,
Day.Wednesday, MonthInterval.Month1);
Yearly panel
Get expression to be run 18th day of every February;
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeYearBasedExpression().setAtTheDayOfEveryMonth(Month.February, 18);
Represents cron expression for first tuesday of every march
QuartzExpressionBuilder builder = new QuartzExpressionBuilder();
builder.makeYearBasedExpression().setDayRankOfEveryMonth(Month.March, Day.Tuesday, Rank.First);