0 votes
in Education by (54.6k points)

How will you get second saturday of next month using java8 in Java8?

1 Answer

0 votes
by (54.6k points)

How will you get second saturday of next month using java8 in Java8?

Following code gets second saturday of next month using java8 -

//get the second saturday of next month

LocalDate firstInYear = LocalDate.of(date1.getYear(),date1.getMonth(), 1);

LocalDate secondSaturday = firstInYear.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY)).with(TemporalAdjusters.next(DayOfWeek.SATURDAY));

System.out.println("Second Saturday on : " + secondSaturday);

...