Java Utility Library

Java GregorianCalendar - getGregorianChange() Method



The java.util.GregorianCalendar.getGregorianChange() method is used to get the Gregorian Calendar 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.

Syntax

public final Date getGregorianChange()

Parameters

No parameter is required.

Return Value

Returns the Gregorian cutover date for this GregorianCalendar object.

Exception

NA.

Example:

In the example below, the java.util.GregorianCalendar.getGregorianChange() method is used to get the Gregorian Calendar change date.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a Calendar object with specified date
    GregorianCalendar Cal = new GregorianCalendar(2015, 10, 30);

    //printing the Calendar
    System.out.println("The Calendar is: " + Cal.getTime());

    //printing the default GregorianCalendar change date
    System.out.println("\nDefault GregorianCalendar change date: ");  
    System.out.println(Cal.getGregorianChange()); 

    //change the GregorianCalendar change date
    GregorianCalendar cal1 = new GregorianCalendar(1995, 10, 30);
    Date Dt = cal1.getTime();
    Cal.setGregorianChange(Dt);

    //printing the modified GregorianCalendar change date
    System.out.println("\nModified GregorianCalendar change date: ");  
    System.out.println(Cal.getGregorianChange());    
  }
}

The output of the above code will be:

The Calendar is: Mon Nov 30 00:00:00 UTC 2015

Default GregorianCalendar change date: 
Fri Oct 15 00:00:00 UTC 1582

Modified GregorianCalendar change date: 
Thu Nov 30 00:00:00 UTC 1995

❮ Java.util - GregorianCalendar