Java Date Time - Java Calendar.getInstance(TimeZone zone, Locale aLocale)








Syntax

Calendar.getInstance(TimeZone zone, Locale aLocale) has the following syntax.

public static Calendar getInstance(TimeZone zone,   Locale aLocale)

Example

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

//from ww  w  .  j  a v a 2s.c  o m

import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

public class Main {

   public static void main(String[] args) {

      // create a calendar
      Locale locale1 = Locale.CANADA;
      TimeZone tz1 = TimeZone.getTimeZone("GMT");
      Calendar cal1 = Calendar.getInstance(tz1, locale1);

      // display time zone for both calendars
      String tzname1 = tz1.getDisplayName();
      String name1 = locale1.getDisplayName();
      System.out.println("GMT and Canada: " + tzname1 + " " + name1);
   }
}

The code above generates the following result.