Calendar getAvailableLocales() Method in Java with Examples

The clear() method in Calendar class is used to return an array of all the locales available at the localized instances of the getInstance method of this class.

Syntax:

public static Locale[] getAvailableLocales()

Parameters: The method does not take any parameters.



Return Value: The method returns an array of all the locales for which the localized instances are available.

Below programs illustrate the working of getAvailableLocales() Method of Calendar class:
Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Code to illustrate
// getAvailableLocales() Method
  
import java.util.*;
  
public class Calendar_Demo_Locale {
    public static void main(String args[])
    {
  
        // Creating a locale object
        Locale loc_arr[] = new Locale[5];
  
        // Assigning locales to array
        loc_arr = Locale.getAvailableLocales();
  
        // Displaying the results
        System.out.println("The first "
                           + "five locales are:");
  
        for (int cnt = 0; cnt < 5; cnt++)
            System.out.println(
                loc_arr[cnt]
                    .getISO3Country());
    }
}

chevron_right


Output:

The first five locales are:

ARE
JOR
SYR
HRV

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java Code to illustrate
// getAvailableLocales() Method
  
import java.util.*;
  
public class Calendar_Demo_Locale {
    public static void main(String args[])
    {
  
        // Creating a locale object
        Locale loc_arr[] = new Locale[20];
  
        // Assigning locales to array
        loc_arr = Locale.getAvailableLocales();
  
        // Displaying the results
        System.out.println("The first "
                           + "twenty availables"
                           + " locales are:");
  
        for (int cnt = 0; cnt < 20; cnt++)
            System.out.println(
                loc_arr[cnt]
                    .getISO3Country());
    }
}

chevron_right


Output:

The first twenty availables locales are:

ARE
JOR
SYR
HRV
BEL
PAN
MLT
VEN

TWN




DNK
PRI
VNM
USA
MNE

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#clone()



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.