// Alternatively, if you don't like infinite streams... public static TemporalAdjuster next_oldschool(Predicate<LocalDate> p) { return TemporalAdjusters.ofDateAdjuster( (d) -> { LocalDate currentToTest = nextDay(d); while (!p.test(currentToTest)) { currentToTest = nextDay(currentToTest); } return currentToTest; }); }
public static TemporalAdjuster next(Predicate<LocalDate> p) { return TemporalAdjusters.ofDateAdjuster( (d) -> Stream.iterate(nextDay(d), Ex3::nextDay).filter(p).findFirst().get()); }