Skip to content
Related Articles

Related Articles

Improve Article

Calendar getAvailableLocales() Method in Java with Examples

  • Last Updated : 14 Feb, 2019
Geek Week

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:






// 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());
    }
}
Output:
The first five locales are:

ARE
JOR
SYR
HRV

Example 2:




// 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());
    }
}
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()

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :