Thursday, June 11, 2026
HomeLanguagesJavaGregorianCalendar getGregorianChange() Method

GregorianCalendar getGregorianChange() Method

The java.util.GregorianCalendar.getGregorianChange() is an inbuilt method in Java which returns the Gregorian Calendar change date which is the change from Julian Calendar dates to Gregorian Calendar dates. It is October 15, 1582 (Gregorian) by default but can be changed using setGregorianDate() function to any other date. All previous dates are present in the Julian Calendar.

Syntax:

public final Date getGregorianChange()

Parameters: The function does not accept any parameters.

Return Values: The function returns the Gregorian Calendar change date for this GregorianCalendar instance.

Examples:

Input : Tue Jul 24 01:22:29 UTC 2018
Output : Fri Oct 15 00:00:00 UTC 1582

Input: Tue Jul 24 01:22:29 UTC 2018
        c.setGregorianChange(new Date());
Output : Tue Jul 24 01:22:29 UTC 2018

Below programs illustrate the java.util.GregorianCalendar.getGregorianChange() function:
Program 1:




// Java Program to illustrate getGregorianChange()
// function 
import java.io.*;
import java.util.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        // Create a new calendar
        GregorianCalendar c = (GregorianCalendar)
                     GregorianCalendar.getInstance();
  
        // Display the current date and time
        System.out.println("Current Date and Time : "
                           + c.getTime());
  
        // Fetch Gregorian change and display it
        System.out.println("Gregorian Date change :"
                           + c.getGregorianChange());
    }
}


Output:

Current Date and Time : Fri Jul 27 12:38:41 UTC 2018
Gregorian Date change :Fri Oct 15 00:00:00 UTC 1582

Program 2:




// Java Program to illustrate getGregorianChange()
// function 
  
import java.io.*;
import java.util.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        // Create a new calendar
        GregorianCalendar c = (GregorianCalendar)
                     GregorianCalendar.getInstance();
  
        // Display the current date and time
        System.out.println("Current Date and Time : "
                           + c.getTime());
  
        // Change to current date
        c.setGregorianChange(new Date());
  
        // Fetch and Display the result
        System.out.println("Gregorian Date change :"
                           + c.getGregorianChange());
    }
}


Output:

Current Date and Time : Fri Jul 27 12:38:44 UTC 2018
Gregorian Date change :Fri Jul 27 12:38:44 UTC 2018

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#getGregorianChange()

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS