public static void validateExpression(String cronExpression, ClockReader clockReader) throws ParseException { new CronExpression(cronExpression, clockReader); }
/** * Indicates whether the specified cron expression can be parsed into a * valid cron expression * * @param cronExpression * the expression to evaluate * @return a boolean indicating whether the given expression is a valid cron * expression */ public static boolean isValidExpression(String cronExpression, ClockReader clockReader) { try { new CronExpression(cronExpression, clockReader); } catch (ParseException pe) { return false; } return true; }
@Override @Deprecated public Object clone() { return new CronExpression(this, clockReader); } }
@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); } }