/** * Returns the next date/time <I>after</I> the given date/time which * satisfies the cron expression. * * @param date * the date/time at which to begin the search for the next valid * date/time * @return the next valid date/time */ public Date getNextValidTimeAfter(Date date) { return getTimeAfter(date); }
/** * Indicates whether the given date satisfies the cron expression. Note that * milliseconds are ignored, so two Dates falling on different milliseconds * of the same second will always have the same result here. * * @param date * the date to evaluate * @return a boolean indicating whether the given date satisfies the cron * expression */ public boolean isSatisfiedBy(Date date) { Calendar testDateCal = Calendar.getInstance(getTimeZone()); testDateCal.setTime(date); testDateCal.set(Calendar.MILLISECOND, 0); Date originalDate = testDateCal.getTime(); testDateCal.add(Calendar.SECOND, -1); Date timeAfter = getTimeAfter(testDateCal.getTime()); return ((timeAfter != null) && timeAfter.equals(originalDate)); }
newDate = getTimeAfter(lastDate); if (newDate == null) break;
@Override public Date resolve(String duedateDescription, ClockReader clockReader, TimeZone timeZone) { Calendar nextRun = null; try { if (duedateDescription.startsWith("R")) { nextRun = new DurationHelper(duedateDescription, clockReader).getCalendarAfter(clockReader.getCurrentCalendar(timeZone)); } else { CronExpression cronExpression = new CronExpression(duedateDescription, clockReader); cronExpression.setTimeZone(timeZone); Date nextRunDate = cronExpression.getTimeAfter(clockReader.getCurrentCalendar(timeZone).getTime()); nextRun = new GregorianCalendar(); nextRun.setTime(nextRunDate); } } catch (Exception e) { throw new FlowableException("Failed to parse scheduler expression: " + duedateDescription, e); } return nextRun == null ? null : nextRun.getTime(); }
@Override public Date resolveDuedate(String duedateDescription, int maxIterations) { try { if (duedateDescription != null && duedateDescription.startsWith("R")) { return new DurationHelper(duedateDescription, maxIterations, clockReader).getDateAfter(); } else { CronExpression ce = new CronExpression(duedateDescription, clockReader); return ce.getTimeAfter(clockReader.getCurrentTime()); } } catch (Exception e) { throw new FlowableException("Failed to parse cron expression: " + duedateDescription, e); } }