public Calendar getCalendarAfter() { return getCalendarAfter(clockReader.getCurrentCalendar()); }
@Override public Date resolveDuedate(String duedate, int maxIterations) { try { // check if due period was specified if(duedate.startsWith("P")){ return new DateTime(clockReader.getCurrentTime()).plus(Period.parse(duedate)).toDate(); } return DateTime.parse(duedate).toDate(); } catch (Exception e) { throw new ActivitiException("couldn't resolve duedate: " + e.getMessage(), e); } } }
/** * Returns the time zone for which this <code>CronExpression</code> will be resolved. */ public TimeZone getTimeZone() { if (timeZone == null) { timeZone = clockReader.getCurrentTimeZone(); } return timeZone; }
@Override public Date resolveEndDate(String endDateString) { return ISODateTimeFormat.dateTimeParser().withZone(DateTimeZone.forTimeZone(clockReader.getCurrentTimeZone())).parseDateTime(endDateString).toCalendar(null).getTime(); }
@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 { nextRun = new CronExpression(duedateDescription, clockReader, timeZone).getTimeAfter(clockReader.getCurrentCalendar(timeZone)); } } catch (Exception e) { throw new ActivitiException("Failed to parse scheduler expression: " + duedateDescription, e); } return nextRun == null ? null : nextRun.getTime(); }
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 ActivitiException("Failed to parse cron expression: " + duedateDescription, e); } }
protected Calendar parseDate(String date) throws Exception { Calendar dateCalendar = null; try { dateCalendar = ISODateTimeFormat.dateTimeParser().withZone(DateTimeZone.forTimeZone( clockReader.getCurrentTimeZone())).parseDateTime(date).toCalendar(null); } catch (IllegalArgumentException e) { // try to parse a java.util.date to string back to a java.util.date dateCalendar = new GregorianCalendar(); DateFormat DATE_FORMAT = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.ENGLISH); dateCalendar.setTime(DATE_FORMAT.parse(date)); } return dateCalendar; }
start = clockReader.getCurrentCalendar();
@Override public Date resolveDuedate(String duedate, int maxIterations) { try { // check if due period was specified if(duedate.startsWith("P")){ return new DateTime(clockReader.getCurrentTime()).plus(Period.parse(duedate)).toDate(); } return DateTime.parse(duedate).toDate(); } catch (Exception e) { throw new ActivitiException("couldn't resolve duedate: " + e.getMessage(), e); } } }
private Calendar getDateAfterRepeat(Calendar date) { Calendar current = TimeZoneUtil.convertToTimeZone(start, date.getTimeZone()); if (repeatWithNoBounds) { while (current.before(date) || current.equals(date)) { // As long as current date is not past the engine date, we keep looping Calendar newTime = add(current, period); if (newTime.equals(current) || newTime.before(current)) { break; } current = newTime; } } else { int maxLoops = times; if (maxIterations > 0) { maxLoops = maxIterations - times; } for (int i = 0; i < maxLoops + 1 && !current.after(date); i++) { current = add(current, period); } } return current.before(date) ? date : TimeZoneUtil.convertToTimeZone(current, clockReader.getCurrentTimeZone()); }
public Calendar getTimeAfter(Calendar afterTime) { Calendar cl = clockReader.getCurrentCalendar(getTimeZone()); // new Calendar tcal = clockReader.getCurrentCalendar(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); Calendar tcal = clockReader.getCurrentCalendar(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0);
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 ActivitiException("Failed to parse cron expression: " + duedateDescription, e); } }
@Override public Date resolveDuedate(String duedateDescription, int maxIterations) { logger.info("Resolving Due Date: " + duedateDescription); String timeZone = getValueFrom("DSTZONE", duedateDescription); String version = getValueFrom("VER", duedateDescription); // START is a legacy value that is no longer used, but may still exist // in // deployed job schedules // Could be used in the future as a start date for a CRON job // String startDate = getValueFrom("START", duedateDescription); duedateDescription = removeValueFrom("VER", removeValueFrom("START", removeValueFrom("DSTZONE", duedateDescription))).trim(); try { logger.info("Base Due Date: " + duedateDescription); Date date = resolvers.get(version == null ? getDefaultScheduleVersion() : Integer.valueOf(version)).resolve(duedateDescription, clockReader, timeZone == null ? clockReader.getCurrentTimeZone() : TimeZone.getTimeZone(timeZone)); logger.info("Calculated Date: " + (date == null ? "Will Not Run Again" : date)); return date; } catch (Exception e) { throw new ActivitiIllegalArgumentException("Cannot parse duration", e); } }
public Calendar getCalendarAfter() { return getCalendarAfter(clockReader.getCurrentCalendar()); }
/** * Returns the time zone for which this <code>CronExpression</code> will be resolved. */ public TimeZone getTimeZone() { if (timeZone == null) { timeZone = clockReader.getCurrentTimeZone(); } return timeZone; }
@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 { nextRun = new CronExpression(duedateDescription, clockReader, timeZone).getTimeAfter(clockReader.getCurrentCalendar(timeZone)); } } catch (Exception e) { throw new ActivitiException("Failed to parse scheduler expression: " + duedateDescription, e); } return nextRun == null ? null : nextRun.getTime(); }
protected Calendar parseDate(String date) throws Exception { Calendar dateCalendar = null; try { dateCalendar = ISODateTimeFormat.dateTimeParser().withZone(DateTimeZone.forTimeZone( clockReader.getCurrentTimeZone())).parseDateTime(date).toCalendar(null); } catch (IllegalArgumentException e) { // try to parse a java.util.date to string back to a java.util.date dateCalendar = new GregorianCalendar(); dateCalendar.setTime(DATE_FORMAT.parse(date)); } return dateCalendar; }
start = clockReader.getCurrentCalendar();
@Override public Date resolveEndDate(String endDateString) { return ISODateTimeFormat.dateTimeParser().withZone(DateTimeZone.forTimeZone(clockReader.getCurrentTimeZone())).parseDateTime(endDateString).toCalendar(null).getTime(); }
public Calendar getTimeAfter(Calendar afterTime) { Calendar cl = clockReader.getCurrentCalendar(getTimeZone()); // new Calendar tcal = clockReader.getCurrentCalendar(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); Calendar tcal = clockReader.getCurrentCalendar(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0);