Assuming that your input data is correct, we could use a Stream API to generate all dates in the given range:
final LocalDate start = LocalDate.parse(startDate, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
final LocalDate end = LocalDate.parse(endDate, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
final int days = (int) start.until(end, ChronoUnit.DAYS);
return Stream.iterate(start, d -> d.plusDays(1))
.limit(days)
.collect(Collectors.toList());
Example:
getDateList("2012/10/10", "2012/10/12")
[2012-10-10, 2012-10-11]
If you want to include the ending date, you need to use .limit(days + 1)
.
Since Java 9, it's possible to simplify this to:
Stream.iterate(start, d -> d.isBefore(end), d -> d.plusDays(1))
.collect(Collectors.toList());
or even:
start.datesUntil(end, Period.ofDays(1));
Just remember to make sure that the inclusion of the last date is handled properly.