Java: How to iterate over days in a Period object

If I have a Period object defined like this:

Period.between(LocalDate.of(2015,8,1), LocalDate.of(2015,9,2))

how to iterate over all days starting from first day until the last one? I need a loop that has an object LocalDate referring to the current date to process it.

Jon Skeet
people
quotationmark

You can't - because a Period doesn't know its start/end dates... it only knows how long it is in terms of years, months, days etc. In that respect, it's a sort of calendar-centric version of Duration.

If you want to create your own, it would be easy to do, of course - but I don't believe there's anything out of the box in either java.time (or Joda Time, as it happens) to do this.

people

See more on this question at Stackoverflow