how to get a list of dates between two dates in java

后端 未结 22 2021
余生分开走
余生分开走 2020-11-22 13:24

I want a list of dates between start date and end date.

The result should be a list of all dates including the start and end date.

22条回答
  •  面向向阳花
    2020-11-22 13:44

    With java 8

    public Stream getDaysBetween(LocalDate startDate, LocalDate endDate) {
        return IntStream.range(0, (int) DAYS.between(startDate, endDate)).mapToObj(startDate::plusDays);
    }
    

提交回复
热议问题