OpeningHoursInterval { public boolean isDateInInterval(Date date) { final int dayOfWeek = DateUtil.getDayOfWeek(date); boolean isInInterval = false; if (getNumberOfDays() == 1) { if (mStartDay == dayOfWeek) { isInInterval = true; } } else { if (dayOfWeek >= mStartDay && dayOfWeek <= mEndDay) { isInInterval = true; } } return isInInterval; } OpeningHoursInterval(int startDay, int endDay, String openingHours);  OpeningHoursInterval(int startDay, String openingHours); int getStartDay(); void setStartDay(int startDay); int getEndDay(); void setEndDay(int endDay); String getOpeningHours(); void setOpeningHours(String openingHours); int getNumberOfDays(); boolean isDateInInterval(Date date); static final String CLOSED; }
@Test public void testIsDateInInterval() throws Exception { final Date date = new GregorianCalendar(2015, GregorianCalendar.JULY, 26).getTime(); OpeningHoursInterval interval = new OpeningHoursInterval(5, 6, "9 - 10"); assertTrue(interval.isDateInInterval(date)); interval = new OpeningHoursInterval(6, "9 - 10"); assertTrue(interval.isDateInInterval(date)); interval = new OpeningHoursInterval(0, 2, "9 - 10"); assertFalse(interval.isDateInInterval(date)); }