Java Date Time - Month MAY example








Month MAY defines the singleton instance for the month of May with 31 days.

This has the numeric value of 5.

Syntax

MAY has the following syntax.

public static final Month MAY

Example

The following example shows how to use MAY.

import java.time.Month;
// w ww  .j  av a2s .  c om
public class Main {
  public static void main(String[] args) {
    Month m = Month.MAY;
    System.out.println(m.getValue());
    System.out.println(m.name());
    System.out.println(m.ordinal());
  }
}

The code above generates the following result.