YearMonth of(int year, int month) example

Description

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;
/*  w w w  .  j av a  2  s .co  m*/
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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset