/** * Compares this program event to the provided date. * * @param compareDate the <code>Date</code> to be compared. * @return the number of milliseconds until the program event starts, if program event is after * the current date; the negative number of milliseconds since the program event ended (should * not occur); or 0 if the program event is within the current date; */ public long compareTo(Date current) { long startTime = getStartTime().getTime(); long endTime = getEndTime().getTime() - 1000; long curTime = current.getTime(); long dxTime = startTime - curTime; if (dxTime > 0) { return dxTime; } dxTime = endTime - curTime; if (dxTime < 0) { return dxTime; } return 0; }
/** * Returns the duration of this program event in seconds. * * @return This program's duration in seconds. */ public long getDuration() { return (endTime.getTime() - startTime.getTime()) / 1000; }
public boolean isIncluded(Date current) { // return true if current is equal/after the startTime and // before the endTime return ((current.getTime() >= getStartTime().getTime()) && (current.getTime() < getEndTime().getTime())); }