Month of(int month) example

Description

Month of(int month) creates an instance of Month from an int value.

Syntax

of has the following syntax.


public static Month of(int month)

Example

The following example shows how to use of.


import java.time.Month;
/*from   w  ww.  jav a 2 s .  c  o m*/
public class Main {
  public static void main(String[] args) {
    Month m = Month.of(1);
    System.out.println(m.getValue());
    System.out.println(m.name());
    System.out.println(m.ordinal());
  }
}

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