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.


/* ww w .  ja v a 2 s.co 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.