Java Calendar AM_PM

Syntax

Calendar.AM_PM has the following syntax.

public static final int AM_PM

Example

In the following code shows how to use Calendar.AM_PM field.


import java.util.Calendar;
import java.util.GregorianCalendar;
/* w w  w .j a  v  a 2 s. c  om*/
public class Main {

  public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();   
    System.out.println(cal.getTime());
    
    cal.set( Calendar.AM_PM, Calendar.AM );
    System.out.println(cal.getTime());
    
  }
}

The code above generates the following result.