DateRange { public boolean contains(Date date) { return (this.startDate != null && this.startDate.compareTo(date) <= 0) && (this.endDate != null && this.endDate.compareTo(date) >= 0); } DateRange();  DateRange(Date start, Date end); void setStartDate(Date start); void setEndDate(Date end); Date getStartDate(); Date getEndDate(); boolean contains(Date date); @Override String toString();  }
@Test public void contains() { DateRange range = new DateRange(TestDateUtil.date(2001, 7, 5), TestDateUtil.date(2010, 7, 4)); assertTrue(range.contains(TestDateUtil.date(2005, 6, 9))); assertFalse(range.contains(TestDateUtil.date(1971, 7, 19))); assertFalse(range.contains(TestDateUtil.date(2012, 4, 19))); assertTrue(range.contains(TestDateUtil.date(2001, 7, 5))); assertTrue(range.contains(TestDateUtil.date(2010, 7, 4))); }