DateUtil { public static List<Date> createDateSequence(DateRange range, EhourConfig config) { List<Date> dateSequence = new ArrayList<>(); Calendar calendar; calendar = DateUtil.getCalendar(config); calendar.setTime(range.getDateStart()); while (calendar.getTime().before(range.getDateEnd())) { DateUtil.nullifyTime(calendar); dateSequence.add(calendar.getTime()); calendar.add(Calendar.DAY_OF_MONTH, 1); } return dateSequence; } private  DateUtil(); static int getWeekNumberForDate(Date date, int configuredFirstDayOfWeek); static void dayOfWeekFix(Calendar calendar); static boolean isWeekend(Calendar calendar); static int getDaysInMonth(Calendar calendar); static int getDaysInMonth(DateTime calendar); static DateRange calendarToMonthRange(Calendar calendar); static boolean isDateWithinRange(Date date, DateRange dateRange); static boolean isDateWithinRange(DateTime date, DateRange dateRange); static boolean isDateWithinRange(Calendar calendar, DateRange dateRange); static boolean isDateRangeOverlaps(DateRange rangeA, DateRange rangeB); static DateRange getDateRangeForWeek(Calendar calendar); static DateRange getDateRangeForMonth(Date date); static DateRange getDateRangeForMonth(Calendar calendar); static DateRange getDateRangeForQuarter(Calendar calendar); static Calendar addQuarter(Calendar calendar, int quarterDelta); static Date nullifyTime(Date date); static void nullifyTime(Calendar cal); static void maximizeTime(Calendar cal); static Date maximizeTime(Date date); static List<Date> createDateSequence(DateRange range, EhourConfig config); static Calendar getCalendar(EhourConfig config); static Calendar getCalendar(Date date); static String getPatternForDateLocale(Locale dateLocale); static String formatDate(Date date, Locale dateLocale); static String formatDate(DateTime date, Locale dateLocale); static String formatDate(LocalDate date, Locale dateLocale); static int fromCalendarToJodaTimeDayInWeek(int dayInWeek);  }
@Test public void testCreateCalendarSequence() { EhourConfig config = mock(EhourConfig.class); when(config.getFirstDayOfWeek()).thenReturn(1); when(config.getTzAsTimeZone()).thenReturn(TimeZone.getDefault()); List<Date> res = DateUtil.createDateSequence(new DateRange(new Date(2007 - 1900, 5 - 1, 2), new Date(2007 - 1900, 5 - 1, 8)), config); assertEquals(7, res.size()); }