Java Date Time - Month JANUARY example








Month JANUARY defines the singleton instance for the month of January with 31 days.

This has the numeric value of 1.

Syntax

JANUARY has the following syntax.

public static final Month JANUARY

Example

The following example shows how to use JANUARY.

import java.time.Month;
// w  w w .  ja v  a  2s . c om
public class Main {
  public static void main(String[] args) {
    Month m = Month.JANUARY;
    System.out.println(m.getValue());
    System.out.println(m.name());
    System.out.println(m.ordinal());
  }
}

The code above generates the following result.