Java Date Time - Year atMonth(Month month) example








Year atMonth(Month month) combines this year with a month to create a YearMonth.

Syntax

atMonth has the following syntax.

public YearMonth atMonth(Month month)

Example

The following example shows how to use atMonth.

import java.time.Month;
import java.time.Year;
import java.time.YearMonth;
//  ww w.j  ava 2  s.  c om
public class Main {
  public static void main(String[] args) {
    Year y = Year.of(2014);
    YearMonth l = y.atMonth(Month.JANUARY);
    System.out.println(l);

  }
}

The code above generates the following result.