Hello! Currently it seems that java.time package does not use Stream API in any way. I think it would be nice to add some methods which produce the streams. For example:
- in class Year: // Returns sequential ordered stream of all months within this Year: Stream<YearMonth> months(); // Returns sequential ordered stream of all days within this Year: Stream<LocalDate> days(); // Returns sequential ordered stream of all years starting from this // Year until the supplied year, exclusive Stream<Year> yearsUntil(Temporal endExclusive); - in class YearMonth: // Returns sequential ordered stream of all days within this YearMonth: Stream<LocalDate> days(); // Returns sequential ordered stream of all months starting from this // YearMonth until the supplied YearMonth, exclusive Stream<YearMonth> monthsUntil(Temporal endExclusive); - in class LocalDate: // Returns sequential ordered stream of all months starting from this // LocalDate until the supplied LocalDate, exclusive Stream<LocalDate> daysUntil(Temporal endExclusive); The implementation of these methods could be quite simple. For example: class Year { public Stream<LocalDate> days() { return IntStream.rangeClosed(1, length()).mapToObj(this::atDay); } } What do you think? With best regards, Tagir Valeev.