/** * Set the CronExpression to the given one. The TimeZone on the passed-in CronExpression over-rides any that was already set on the Trigger. * * @param cronExpression */ public void setCronExpression(CronExpression cronExpression) { this.cronEx = cronExpression; this.timeZone = cronExpression.getTimeZone(); }
/** * Set the CronExpression to the given one. The TimeZone on the passed-in CronExpression * over-rides any that was already set on the Trigger. * * @param cronExpression */ public void setCronExpression(CronExpression cronExpression) { this.cronEx = cronExpression; this.timeZone = cronExpression.getTimeZone(); }
/** * Set the CronExpression to the given one. The TimeZone on the passed-in CronExpression over-rides any that was already set on the Trigger. * * @param cronExpression */ public void setCronExpression(CronExpression cronExpression) { this.cronEx = cronExpression; this.timeZone = cronExpression.getTimeZone(); }
@Override public TimeZone getTimeZone() { if (cronEx != null) { return cronEx.getTimeZone(); } if (timeZone == null) { timeZone = TimeZone.getDefault(); } return timeZone; }
@Override public TimeZone getTimeZone() { if (cronEx != null) { return cronEx.getTimeZone(); } if (timeZone == null) { timeZone = TimeZone.getDefault(); } return timeZone; }
@Override public TimeZone getTimeZone() { if (cronEx != null) { return cronEx.getTimeZone(); } if (timeZone == null) { timeZone = TimeZone.getDefault(); } return timeZone; }
/** * 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))); }
/** * 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))); }
/** * 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))); }
/** * Returns the next date/time <I>after</I> the given date/time which does <I>not</I> satisfy the expression * * @param date the date/time at which to begin the search for the next invalid date/time * @return the next valid date/time */ public Date getNextInvalidTimeAfter(Date date) { long difference = 1000; //move back to the nearest second so differences will be accurate Calendar adjustCal = Calendar.getInstance(getTimeZone()); adjustCal.setTime(date); adjustCal.set(Calendar.MILLISECOND, 0); Date lastDate = adjustCal.getTime(); Date newDate; //FUTURE_TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution. //keep getting the next included time until it's farther than one second // apart. At that point, lastDate is the last valid fire time. We return // the second immediately following it. while (difference == 1000) { newDate = getTimeAfter(lastDate); if (newDate == null) { break; } difference = newDate.getTime() - lastDate.getTime(); if (difference == 1000) { lastDate = newDate; } } return new Date(lastDate.getTime() + 1000); }
/** * Returns the next date/time <I>after</I> the given date/time which does <I>not</I> satisfy the expression * * @param date the date/time at which to begin the search for the next invalid date/time * @return the next valid date/time */ public Date getNextInvalidTimeAfter(Date date) { long difference = 1000; //move back to the nearest second so differences will be accurate Calendar adjustCal = Calendar.getInstance(getTimeZone()); adjustCal.setTime(date); adjustCal.set(Calendar.MILLISECOND, 0); Date lastDate = adjustCal.getTime(); Date newDate; //FUTURE_TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution. //keep getting the next included time until it's farther than one second // apart. At that point, lastDate is the last valid fire time. We return // the second immediately following it. while (difference == 1000) { newDate = getTimeAfter(lastDate); if (newDate == null) { break; } difference = newDate.getTime() - lastDate.getTime(); if (difference == 1000) { lastDate = newDate; } } return new Date(lastDate.getTime() + 1000); }
Calendar adjustCal = Calendar.getInstance(getTimeZone()); adjustCal.setTime(date); adjustCal.set(Calendar.MILLISECOND, 0);
/** * Constructs a new {@code CronExpression} as a copy of an existing instance. * * @param expression The existing cron expression to be copied */ public CronExpression(CronExpression expression) { /* * We don't call the other constructor here since we need to swallow the ParseException. We also avoid some of the sanity checking as it is not * logically trippable. */ this.cronExpression = expression.getCronExpression(); try { buildExpression(cronExpression); } catch (ParseException ex) { throw new AssertionError(); } if (expression.getTimeZone() != null) { setTimeZone((TimeZone) expression.getTimeZone().clone()); } }
/** * Constructs a new {@code CronExpression} as a copy of an existing instance. * * @param expression The existing cron expression to be copied */ public CronExpression(CronExpression expression) { /* * We don't call the other constructor here since we need to swallow the ParseException. We also avoid some of the sanity checking as it is not * logically trippable. */ this.cronExpression = expression.getCronExpression(); try { buildExpression(cronExpression); } catch (ParseException ex) { throw new AssertionError(); } if (expression.getTimeZone() != null) { setTimeZone((TimeZone) expression.getTimeZone().clone()); } }
/** * Constructs a new {@code CronExpression} as a copy of an existing instance. * * @param expression The existing cron expression to be copied */ public CronExpression(CronExpression expression) { /* * We don't call the other constructor here since we need to swallow the ParseException. We also avoid some of the sanity checking as it is not * logically trippable. */ this.cronExpression = expression.getCronExpression(); try { buildExpression(cronExpression); } catch (ParseException ex) { throw new AssertionError(); } if (expression.getTimeZone() != null) { setTimeZone((TimeZone) expression.getTimeZone().clone()); } }
public Date getTimeAfter(Date afterTime) { Calendar cl = new java.util.GregorianCalendar(getTimeZone()); day -= lastdayOffset; java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); day = daysOfMonth.first(); java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0);
public Date getTimeAfter(Date afterTime) { Calendar cl = new java.util.GregorianCalendar(getTimeZone()); day -= lastdayOffset; java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); day = daysOfMonth.first(); java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0);
public Date getTimeAfter(Date afterTime) { Calendar cl = new java.util.GregorianCalendar(getTimeZone()); day -= lastdayOffset; java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0); day = daysOfMonth.first(); java.util.Calendar tcal = java.util.Calendar.getInstance(getTimeZone()); tcal.set(Calendar.SECOND, 0); tcal.set(Calendar.MINUTE, 0);