Open In App

GregorianCalendar getGregorianChange() Method

Improve
Improve
Like Article
Like
Save
Share
Report

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



Last Updated : 27 Jul, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads