Java Date Time - 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.

/*w w w .  j  av  a2 s .  co m*/
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.