Example usage for java.time.temporal TemporalAdjusters dayOfWeekInMonth

List of usage examples for java.time.temporal TemporalAdjusters dayOfWeekInMonth

Introduction

In this page you can find the example usage for java.time.temporal TemporalAdjusters dayOfWeekInMonth.

Prototype

public static TemporalAdjuster dayOfWeekInMonth(int ordinal, DayOfWeek dayOfWeek) 

Source Link

Document

Returns the day-of-week in month adjuster, which returns a new date with the ordinal day-of-week based on the month.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDate ld1 = LocalDate.of(2014, Month.MAY, 21);
    System.out.println(ld1);//w w w.ja  v  a 2s.c o  m
    LocalDate ld2 = ld1.with(TemporalAdjusters.dayOfWeekInMonth(5, DayOfWeek.SUNDAY));
    System.out.println(ld2);
}

From source file:Main.java

private LocalDate getMartinLutherKingDayForDateInYear(int year) {
    return LocalDate.of(year, Month.JANUARY, 1).with(TemporalAdjusters.dayOfWeekInMonth(3, DayOfWeek.MONDAY));
}