### Question:
TimeApi { public static List<Date> getDatesBetweenUsingJava7(Date startDate, Date endDate) { List<Date> datesInRange = new ArrayList<Date>(); Calendar calendar = new GregorianCalendar(); calendar.setTime(startDate); Calendar endCalendar = new GregorianCalendar(); endCalendar.setTime(endDate); while (calendar.before(endCalendar)) { Date result = calendar.getTime(); datesInRange.add(result); calendar.add(Calendar.DATE, 1); } return datesInRange; }  static List<Date> getDatesBetweenUsingJava7(Date startDate, Date endDate); static List<LocalDate> getDatesBetweenUsingJava8(LocalDate startDate, LocalDate endDate); static List<LocalDate> getDatesBetweenUsingJava9(LocalDate startDate, LocalDate endDate);  }### Answer:
@Test public void givenGetDatesBetweenWithUsingJava7_WhenStartEndDate_thenDatesList() { Date startDate = Calendar.getInstance().getTime(); Calendar endCalendar = Calendar.getInstance(); endCalendar.add(Calendar.DATE, 2); Date endDate = endCalendar.getTime(); List<Date> dates = TimeApi.getDatesBetweenUsingJava7(startDate, endDate); assertEquals(dates.size(), 2); Calendar calendar = Calendar.getInstance(); Date date1 = calendar.getTime(); assertEquals(dates.get(0).getDay(), date1.getDay()); assertEquals(dates.get(0).getMonth(), date1.getMonth()); assertEquals(dates.get(0).getYear(), date1.getYear()); calendar.add(Calendar.DATE, 1); Date date2 = calendar.getTime(); assertEquals(dates.get(1).getDay(), date2.getDay()); assertEquals(dates.get(1).getMonth(), date2.getMonth()); assertEquals(dates.get(1).getYear(), date2.getYear()); }