Example usage for java.util GregorianCalendar GregorianCalendar

List of usage examples for java.util GregorianCalendar GregorianCalendar

Introduction

In this page you can find the example usage for java.util GregorianCalendar GregorianCalendar.

Prototype

public GregorianCalendar() 

Source Link

Document

Constructs a default GregorianCalendar using the current time in the default time zone with the default Locale.Category#FORMAT FORMAT locale.

Usage

From source file:Main.java

public static void main(String[] a) {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.set(1995, 10, 29); // Date set to 29th November 1999
}

From source file:Main.java

public static void main(String[] args) {
    GregorianCalendar cal = new GregorianCalendar();

    // print a hashcode for cal
    System.out.println(cal.hashCode());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = new GregorianCalendar();

    System.out.println(cal.getTime());

}

From source file:Main.java

public static void main(String[] args) {

    GregorianCalendar cal = new GregorianCalendar();

    // clone object cal into object y
    GregorianCalendar y = (GregorianCalendar) cal.clone();

    // print both cal and y
    System.out.println(cal.getTime());
    System.out.println(y.getTime());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    GregorianCalendar cal = new GregorianCalendar();
    boolean b = cal.isLeapYear(1998); // false
    b = cal.isLeapYear(2000); // true
    b = cal.isLeapYear(0); // true
}

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.MILLISECOND));

}

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.DST_OFFSET));

}

From source file:Main.java

public static void main(String[] args) {

    Calendar cal = new GregorianCalendar();
    System.out.println(cal.get(Calendar.ZONE_OFFSET));

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GregorianCalendar gc = new GregorianCalendar();
    gc.setLenient(false);/*from www. j  a  va  2  s  .  co m*/
    gc.set(GregorianCalendar.YEAR, 2003);
    gc.set(GregorianCalendar.MONTH, 12);
    gc.set(GregorianCalendar.DATE, 1);

    gc.getTime();

}

From source file:Main.java

public static void main(String[] a) {
    GregorianCalendar calendar = new GregorianCalendar();
    Date now = calendar.getTime();
    System.out.println(now);//from   w  w w.j ava 2 s . c om
}