KayV
KayV

Reputation: 13835

How to find first sunday of next month in Java 8?

I searched on StackOverflow for the same, but all the answers are for legacy java versions. I did not find any of the answers with Java 8 Data and Time utility. Can anybody help me out for the same?

Upvotes: 0

Views: 662

Answers (1)

KayV
KayV

Reputation: 13835

I find out a way using LocalDate and TemporalAdjuster's with() method as follows:

LocalDate firstSundayOfNextMonth = LocalDate
              .now()
              .with(firstDayOfNextMonth())
              .with(nextOrSame(DayOfWeek.SUNDAY));

Upvotes: 3

Related Questions