JSR-310 Spliterators
![Maven Central](https://camo.githubusercontent.com/f6f205817630792c66fb5c63e8a18b7a9b01e0c6576ee0b1e7e9e74f6b739ed1/68747470733a2f2f6d6176656e2d6261646765732e6865726f6b756170702e636f6d2f6d6176656e2d63656e7472616c2f636f6d2e6769746875622e6d6172736368616c6c2f746872656574656e2d73706c6974657261746f72732f62616467652e737667)
Spliterators for JSR-310 (Java Date Time API) data types allowing you to create streams over JSR-310 data types.
For example you can iterate over all days in a year
LocalDateStreams.range(LocalDate.of(2016, 1, 1), LocalDate.of(2016, 2, 1))
.forEach((localDate) -> {
// body
});
or over all months in a year
YearMonthStreams.rangeClosed(YearMonth.of(2016, 1), YearMonth.of(2016, 12))
.forEach((yearMonth) -> {
// body
});
Besides the predefined iterations by day for LocalDate
and month for YearMonth
we offer a generic way to iterate over any Temporal
with any increment given by a TemporalAdjuster
.
For example you can iterate over all Mondays.
LocalDate start = LocalDate.of(2016, 1, 1).with(nextOrSame(MONDAY));
LocalDate end = LocalDate.of(2016, 1, 1).with(lastDayOfMonth());
TemporalStreams.rangeClosed(start, end, next(MONDAY))
.forEach((localDate) -> {
// body
});
All the stream methods like #map
or #filter
are available.
For more information check out the Javadoc.