GregorianCalendar getTimeZone() Method in Java Last Updated : 27 Jul, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.util.GregorianCalendar.getTimeZone() method is an in-built method in Java which fetches the time zone and returns the TimeZone object associated with this calendar. Syntax: public TimeZone getTimeZone() Parameters: This method does not accept any parameter.Return Values: This method returns a TimeZone object which denotes the time zone of this calendar. Examples: Input : Mon Jul 23 19:45:33 UTC 2018 Output : Coordinated Universal Time Input : Wed Oct 23 20:02:52 UTC 2019 cal.setTimeZone(TimeZone.getTimeZone("CST")); Output : Central Standard Time Below programs illustrate the java.util.GregorianCalendar.getTimeZone() function in Java: Program 1: Java // Java Program to illustrate // GregorianCalendar.getTimeZone() // function import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // Create a new calendar GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); //Display the current date and time System.out.println("Current Date and Time : " + cal.getTime()); /* Creating a Time Zone object and storing this TimeZone */ TimeZone t = cal.getTimeZone(); // Display the time zone System.out.println("Time Zone : " + t.getDisplayName()); } } Output: Current Date and Time : Wed Jul 25 11:25:16 UTC 2018 Time Zone : Coordinated Universal Time Program 2: In this program, we use setTimeZone() to change the current time zone and then fetch the new time zone using getTimeZone() method. Java // Java Program to illustrate // GregorianCalendar.getTimeZone() // function import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // Create a new calendar GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); // Display the current date and time System.out.println("Current Date and Time : " + cal.getTime()); // Changing the current time zone cal.setTimeZone(TimeZone.getTimeZone("CST")); /* Creating a Time Zone object and storing the TimeZone */ TimeZone t = cal.getTimeZone(); // Display the time zone System.out.println("Time Zone : " + t.getDisplayName()); } } Output: Current Date and Time : Wed Jul 25 11:25:22 UTC 2018 Time Zone : Central Standard Time Reference: https://docs.oracle.com/javase/7/docs/api/java/util/GregorianCalendar.html#getTimeZone() Comment More infoAdvertise with us Next Article GregorianCalendar getTimeZone() Method in Java R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Java Java - util package Java-Functions Practice Tags : JavaMisc Similar Reads GregorianCalendar add() Method in Java The java.util.GregorianCalendar.add(int calendarfield, int time) is an in-built method of GregorianCalendar class in Java. The function accepts a calendar field and the amount of time to be added to that particular calendar field as a parameter. Based on the calendar rules, the method adds or deduct 3 min read 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() fun 2 min read GregorianCalendar setTimeZone() Method in Java The java.util.GregorianCalendar.setTimeZone() method is an in-built method in Java which modifies the current time zone to a new time zone according to the parameter passed. Syntax: public void setTimeZone(TimeZone tz) Parameters: The method takes one parameter tz of TimeZone object which specifies 2 min read Java.util.GregorianCalendar Class in Java Prerequisites : java.util.Locale, java.util.TimeZone, Calendar.get()GregorianCalendar is a concrete subclass(one which has implementation of all of its inherited members either from interface or abstract class) of a Calendar that implements the most widely used Gregorian Calendar with which we are f 10 min read DateFormat getCalendar() Method in Java with Examples The getCalendar() Method of DateFormat class in Java is used to get the calendar associated with this date/time format object. Syntax: public Calendar getCalendar() Parameter: The method does not take any parameters. Return Value: The method returns an instance of Calendar for this DateFormat object 2 min read Like