Java.util.Calendar.getTimeZone() Method
Advertisements
Description
The java.util.Calendar.getTimeZone() method gets the time zone.
Declaration
Following is the declaration for java.util.Calendar.getTimeZone() method
public TimeZone getTimeZone()
Parameters
NA
Return Value
The method returns the time zone object.
Exception
NA
Example
The following example shows the usage of java.util.calendar.getTimeZone() method.
package com.tutorialspoint;
import java.util.*;
public class CalendarDemo {
public static void main(String[] args) {
// create a calendar
Calendar cal = Calendar.getInstance();
// get the time zone
TimeZone tz = cal.getTimeZone();
// print the time zone name for this calendar
System.out.println("The time zone is :" + tz.getDisplayName());
}
}
Let us compile and run the above program, this will produce the following result:
The time zone is :Eastern European Time