Java.util.GregorianCalendar.setGregorianChange() Method

Advertisements


Description

The java.util.GregorianCalendar.setGregorianChange(Date date) method sets the GregorianCalendar change date. This is the point when the switch from Julian dates to Gregorian dates occurred. Default is October 15, 1582 (Gregorian). Previous to this, dates will be in the Julian calendar.

Declaration

Following is the declaration for java.util.GregorianCalendar.setGregorianChange() method

public void setGregorianChange(Date date)

Parameters

  • date -- the given Gregorian cutover date.

Return Value

This method does not return a value.

Exception

  • NA

Example

The following example shows the usage of java.util.GregorianCalendar.setGregorianChange() method.

package com.tutorialspoint;

import java.util.*;

public class GregorianCalendarDemo {

   public static void main(String[] args) {

      // create a new calendar
      GregorianCalendar cal =
              (GregorianCalendar) GregorianCalendar.getInstance();

      // print the current date and time
      System.out.println("" + cal.getTime());

      // set gregorian change at another date
      cal.setGregorianChange(new Date(92, 12, 10));
      System.out.println("Gregorian Change Date" + cal.getGregorianChange());

   }
}

Let us compile and run the above program, this will produce the following result:

Fri May 18 13:43:31 EEST 2012
Gregorian Change DateSun Jan 10 00:00:00 EET 1993



Advertisements
Advertisements