1 package org.oddjob.schedules.schedules; 2 3 import java.io.Serializable ; 4 import java.text.ParseException ; 5 import java.util.Date ; 6 7 import org.oddjob.schedules.RegularSchedule; 8 import org.oddjob.util.DateHelper; 9 10 23 24 final public class IntervalSchedule extends RegularSchedule implements Serializable { 25 26 private static final long serialVersionUID = 20050226; 27 28 31 private Long intervalMillis; 32 33 41 public void setInterval(String interval) throws ParseException { 42 intervalMillis = new Long (DateHelper.parseTime(interval)); 43 } 44 45 49 public Date next(Date from) { 50 if (intervalMillis == null) { 51 return new Date (Long.MAX_VALUE); 52 } 53 return new Date (from.getTime() + intervalMillis.longValue()); 54 } 55 } 56 | Popular Tags |