IntervalOfTime implements Cloneable { public static IntervalOfTime convexHull(IntervalOfTime i1, IntervalOfTime i2) { PointInTime t1; PointInTime t2; boolean lowClosed; boolean highClosed; if (i1.low.before(i2.low)) { t1 = i1.low; lowClosed = i1.isLowClosed(); } else { t1 = i2.low; lowClosed = i2.isLowClosed(); } if (i1.high.after(i2.high)) { t2 = i1.high; highClosed = i1.isHighClosed(); } else { t2 = i2.high; highClosed = i2.isHighClosed(); } return new IntervalOfTime(t1, t2, lowClosed, highClosed); } IntervalOfTime(PointInTime low, PointInTime high);  IntervalOfTime(PointInTime low, PointInTime high, boolean lowClosed,
                          boolean highClosed);  IntervalOfTime(PointInTime low, PointInTime high,
                          boolean equalEndpointsAllowed);  IntervalOfTime(PointInTime low, PointInTime high, boolean lowClosed,
                          boolean highClosed, boolean equalEndpointsAllowed); PointInTime getLow(); PointInTime getHigh(); PointInTime getCenter(); Duration getWidth(); Period toPeriod(); Period toPeriod(PeriodType periodType); boolean isLowClosed(); boolean isHighClosed(); PointInTime demote(); IntervalOfTime toClosed(); String toString(); boolean contains(PointInTime t); boolean contains(IntervalOfTime i); Object clone(); IntervalOfTime intersection(IntervalOfTime i); IntervalOfTime hull(IntervalOfTime i); boolean equals(Object obj); int hashCode(); static IntervalOfTime intersection(IntervalOfTime i1,
                                              IntervalOfTime i2); static IntervalOfTime convexHull(IntervalOfTime i1, IntervalOfTime i2); static IntervalOfTime today(); static IntervalOfTime thisMonth(); static IntervalOfTime thisYear(); static IntervalOfTime yearToDate(); static IntervalOfTime forYear(int year); static IntervalOfTime forMonth(int year, int month); static IntervalOfTime forDay(int year, int month, int date); static IntervalOfTime forTheLast(ReadablePeriod p); static IntervalOfTime forTheLast(int years); static IntervalOfTime forTheLast(int years, int months); static IntervalOfTime forTheLast(int years, int months, int days); static IntervalOfTime forTheLast(int years, int months, int days, int hours, int minutes, int seconds, int milliseconds); static IntervalOfTime forTheNext(ReadablePeriod p); static IntervalOfTime forTheNext(int years); static IntervalOfTime forTheNext(int years, int months); static IntervalOfTime forTheNext(int years, int months, int days); static IntervalOfTime forTheNext(int years, int months, int days, int hours, int minutes, int seconds, int milliseconds); static IntervalOfTime since(PointInTime t); static IntervalOfTime since(int year); static IntervalOfTime since(int year, int month); static IntervalOfTime since(int year, int month, int date); static IntervalOfTime since(int year, int month, int date, int hour); static IntervalOfTime since(int year, int month, int date, int hour, int minute); static IntervalOfTime since(int year, int month, int date, int hour, int minute, int second); static IntervalOfTime since(int year, int month, int date, int hour, int minute, int second, int millisecond); static IntervalOfTime untilNow(ReadablePeriod p); static IntervalOfTime untilToday(ReadablePeriod p);  }
@Test public void testConvexHull() { PointInTime t1 = new PointInTime(1975); PointInTime t2 = new PointInTime(1990); Assert.assertNotNull(t1.promote().hull(t2.promote())); IntervalOfTime i1 = new IntervalOfTime(new PointInTime(1975), new PointInTime(1984)); IntervalOfTime i2 = new IntervalOfTime(new PointInTime(1980), new PointInTime(1990)); IntervalOfTime h1 = i1.hull(i2); Assert.assertTrue(h1.isLowClosed()); Assert.assertFalse(h1.isHighClosed()); assertEquals(1975, 1, 1, 0, 0, 0, 0, h1.getLow()); assertEquals(1991, 1, 1, 0, 0, 0, 0, h1.getHigh()); IntervalOfTime h2 = i2.hull(i1); Assert.assertTrue(h1.equals(h2)); }