Open In App

Calendar getAvailableLocales() Method in Java with Examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

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()



Last Updated : 14 Feb, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads