alexander.egger’s answer is correct and shows us the building blocks we need (+1). For the question as stated the only TemporalAdjuster
we need is the one we get from the library. The following may feel a bit simpler:
LocalDate current = LocalDate.now(ZoneId.of("Pacific/Easter"));
LocalDate secondSundayOfNextMonth = current.plusMonths(1)
.with(TemporalAdjusters.dayOfWeekInMonth(2, DayOfWeek.SUNDAY));
System.out.println("2nd Sunday of next month is " + secondSundayOfNextMonth);
Output running today was:
2nd Sunday of next month is 2018-08-12
Since the month doesn’t begin at the same time in different time zones, I have preferred to give explicit time zone to LocalDate.now
.
“Everything Should Be Made as Simple as Possible, But Not Simpler” (I think I read it from Bjarne Stroustrup, but he probably stole it somewhere else).
LocalDateTime.now().withDayOfMonth(1).plusMonths(1).with(TemporalAdjusters.next(DayOfWeek.SUNDAY)).with(TemporalAdjusters.next(DayOfWeek.SUNDAY));
which comes up with2018-08-12T13:34:15.734
, but there might be a simpler way