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

后端 未结 22 1830
余生分开走
余生分开走 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:36

    With Lamma it looks like this in Java:

        for (Date d: Dates.from(2014, 6, 29).to(2014, 7, 1).build()) {
            System.out.println(d);
        }
    

    and the output is:

        Date(2014,6,29)
        Date(2014,6,30)
        Date(2014,7,1)
    

提交回复
热议问题