Calendar getAvailableLocales() Method in Java with Examples
Last Updated :
14 Feb, 2019
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:
import java.util.*;
public class Calendar_Demo_Locale {
public static void main(String args[])
{
Locale loc_arr[] = new Locale[ 5 ];
loc_arr = Locale.getAvailableLocales();
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:
import java.util.*;
public class Calendar_Demo_Locale {
public static void main(String args[])
{
Locale loc_arr[] = new Locale[ 20 ];
loc_arr = Locale.getAvailableLocales();
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()
Share your thoughts in the comments
Please Login to comment...