Java Date Time - Java Calendar.getInstance(TimeZone zone)








Syntax

Calendar.getInstance(TimeZone zone) has the following syntax.

public static Calendar getInstance(TimeZone zone)

Example

In the following code shows how to use Calendar.getInstance(TimeZone zone) method.

//from  w w w  .  j  a  v  a  2s  .c o m
import java.util.Calendar;
import java.util.TimeZone;

public class Main {

   public static void main(String[] args) {

      TimeZone tz1 = TimeZone.getTimeZone("GMT");
      Calendar cal1 = Calendar.getInstance(tz1);


      // display time zone for both calendars
      System.out.println("GMT: " + cal1.getTimeZone().getDisplayName());
   }
}

The code above generates the following result.