//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;
}
}
returnnewDate(lastDate.getTime()+1000);
}
/**
* Returns the time zone for which this <code>CronExpression</code>
* will be resolved.
*/
publicTimeZonegetTimeZone(){
if(timeZone==null){
timeZone=TimeZone.getDefault();
}
returntimeZone;
}
/**
* Sets the time zone for which this <code>CronExpression</code>
* will be resolved.
*/
publicvoidsetTimeZone(TimeZonetimeZone){
this.timeZone=timeZone;
}
/**
* Returns the string representation of the <CODE>CronExpression</CODE>
*
* @return a string representation of the <CODE>CronExpression</CODE>
*/
@Override
publicStringtoString(){
returncronExpression;
}
/**
* 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