Skip to content
Related Articles

Related Articles

Improve Article
GregorianCalendar getGregorianChange() Method
  • Last Updated : 27 Jul, 2018

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()

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :