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








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

Syntax

of has the following syntax.

public static YearMonth of(int year,   int month)

Example

The following example shows how to use of.

import java.time.YearMonth;
//from w  w  w. ja  v  a 2 s .  com
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.of(2013,9);
    
    System.out.println(y);

  }
}

The code above generates the following result.