return new DateSpan(Math.min(i1.getStart(),i2.getStart()),Math.max(i1.getEnd(),i2.getEnd()));
}
public boolean add(Object o) {
DateSpan toAdd=(DateSpan)o;
SortedSet set=headSet(o);
if (set.size()>0){
DateSpan interval=(DateSpan)set.last();
if (interval.getEnd()>=toAdd.getStart())
toAdd=mergeIntervals(toAdd,interval);
}
set=tailSet(o);
if (set.size()>0){
DateSpan interval=(DateSpan)set.first();
if (toAdd.getEnd()>=interval.getStart())
toAdd=mergeIntervals(toAdd,interval);
}
return super.add(toAdd);
}