Java Calendar.getTimeZone()

Syntax

Calendar.getTimeZone() has the following syntax.

public TimeZone getTimeZone()

Example

In the following code shows how to use Calendar.getTimeZone() method.


//from w w  w.  j  a va  2 s.  com
import java.util.Calendar;
import java.util.TimeZone;

public class Main {

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

   }
}

The code above generates the following result.