Java Date Time - YearMonth of(int year, Month month) example








YearMonth of(int year, Month month) creates an instance of YearMonth from a year and month.

Syntax

of has the following syntax.

public static YearMonth of(int year,   Month month)

Example

The following example shows how to use of.

import java.time.Month;
import java.time.YearMonth;
//www .ja v a  2s.c o m
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.of(2013,Month.JANUARY);
    
    System.out.println(y);

  }
}

The code above generates the following result.