Java Date Time - Java GregorianCalendar .getTimeZone ()








Syntax

GregorianCalendar.getTimeZone() has the following syntax.

public TimeZone getTimeZone()

Example

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

//from   ww w  .  j a va2s . c o m

import java.util.*;

public class Main {

   public static void main(String[] args) {


      GregorianCalendar cal =
              (GregorianCalendar) GregorianCalendar.getInstance();


      // get the time zone and print it
      System.out.println("Time Zone:" + cal.getTimeZone().getDisplayName());

   }
}

The code above generates the following result.