Set GregorianCalendar with Year, Month and Date in Java

Description

The following code shows how to set GregorianCalendar with Year, Month and Date.

Example


//  ww w  .ja v  a  2s .c o m
import java.util.GregorianCalendar;

public class Main {
  public static void main(String[] argv) throws Exception {
    GregorianCalendar gc = new GregorianCalendar();
    gc.setLenient(false);
    gc.set(GregorianCalendar.YEAR, 2003);
    gc.set(GregorianCalendar.MONTH, 12);
    gc.set(GregorianCalendar.DATE, 1);

    gc.getTime();

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Date »




Date Get
Date Set
Date Format
Date Compare
Date Convert
Date Calculation
Date Parse
Timezone