sascha@4089: package de.intevation.aft; sascha@4089: sascha@4089: import java.util.Date; sascha@4089: sascha@4089: public class TimeInterval sascha@4089: implements Comparable sascha@4089: { sascha@4089: protected int id; sascha@4089: protected Date start; sascha@4089: protected Date stop; sascha@4089: sascha@4089: public TimeInterval() { sascha@4089: } sascha@4089: sascha@4090: public TimeInterval(Date start, Date stop) { sascha@4089: this.start = start; sascha@4089: this.stop = stop; sascha@4089: } sascha@4089: sascha@4090: public TimeInterval(int id, Date start, Date stop) { sascha@4090: this(start, stop); sascha@4090: this.id = id; sascha@4090: } sascha@4090: sascha@4089: protected static int compare(Date d1, Date d2) { sascha@4089: long s1 = d1 != null ? d1.getTime()/1000L : 0L; sascha@4089: long s2 = d2 != null ? d2.getTime()/1000L : 0L; sascha@4089: long diff = s1 - s2; teichmann@4736: return diff < 0L sascha@4089: ? -1 sascha@4089: : diff > 0L ? 1 : 0; sascha@4089: } sascha@4089: sascha@4089: @Override sascha@4089: public int compareTo(TimeInterval other) { sascha@4089: int cmp = compare(start, other.start); teichmann@4736: return cmp != 0 sascha@4089: ? cmp sascha@4089: : compare(stop, other.stop); sascha@4089: } sascha@4089: sascha@4089: public int getId() { sascha@4089: return id; sascha@4089: } sascha@4089: sascha@4089: public void setId(int id) { sascha@4089: this.id = id; sascha@4089: } sascha@4089: sascha@4089: public Date getStart() { sascha@4089: return start; sascha@4089: } sascha@4089: sascha@4089: public void setStart(Date start) { sascha@4089: this.start = start; sascha@4089: } sascha@4089: sascha@4089: public Date getStop() { sascha@4089: return stop; sascha@4089: } sascha@4089: sascha@4089: public void setStop(Date stop) { sascha@4089: this.stop = stop; sascha@4089: } sascha@4101: sascha@4101: public String toString() { sascha@4101: return "[TimeInterval: start=" + start + ", stop=" + stop + "]"; sascha@4101: } sascha@4089: } sascha@4089: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :