Java.util.Calendar.getAvailableLocales() Method

Advertisements


Description

The java.util.Calendar.getAvailableLocales() method returns an array of locales for which the getInstance methods of this class can return localized instances.

Declaration

Following is the declaration for java.util.Calendar.getAvailableLocales() method

public static Locale[] getAvailableLocales()

Parameters

  • NA

Return Value

Returns an array of locales for which localized Calendar instances are available.

Exception

  • NA

Example

The following example shows the usage of java.util.calendar.getAvailableLocales() method.

package com.tutorialspoint;

import java.util.*;

class CalendarGetAvailableLocalesEx {

   public static void main(String args[]) {

      // create an object of locale class 
      Locale[] array = new Locale[10];

      // get available locales and assign them to array
      array = Locale.getAvailableLocales();

      // print the results
      System.out.println("The first 10 locales installed are :-\n");
      for (int i = 0; i < 10; i++) {
         System.out.println(array[i].getISO3Country());
      }
   }
}

Let us compile and run the above program, this will produce the following result:

The first 10 locales installed are :-

JPN
PER

JPN
PAN
BIH

GTM
ARE
NOR



Advertisements
Advertisements