java.util.Calendar getAvailableLocales()方法
java.util.Calendar.getAvailableLocales() 方法返回Java运行时环境中所有可用语言环境的数组。语言环境数组包含可用于本地化Calendar实例的语言环境。getAvailableLocals() 方法是静态方法。
1 语法
public static Locale[] getAvailableLocales()
2 参数
无
3 返回值
此方法以数组形式返回java运行时环境中的所有可用语言环境。
4 示例1
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getAvailableLocales()方法的例子
*/
import java.util.Locale;
public class JavaCalendargetavailablelocalsExample1 {
public static void main(String args[]) {
// an object of local class called strlocal(array) is created
Locale[] strlocal = new Locale[5];
// all available locals are accessed and stored in strlocal
strlocal = Locale.getAvailableLocales();
// print all available locals
System.out.println("The first 5 locales installed in runtime environment are :-\n");
for (int i = 0; i < 6; i++) {
System.out.println(strlocal[i].getISO3Country());
}
}
}
输出结果为:
The first 5 locales installed in runtime environment are :-
ARE
JOR
SYR
HRV
BEL
5 示例2
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getAvailableLocales()方法的例子
*/
import java.util.Locale;
public class JavaCalendargetavailablelocalsExample2 {
public static void main(String args[]) {
// // an object of local class called lclarray(array) is created
Locale[] lclarray = new Locale[5];
// all available locals are accessed and stored in strlocal
lclarray = Locale.getAvailableLocales();
// print the results
System.out.println("The first 5 locales installed in runtime environment are :-\n");
for (int i = 0; i < 6; i++) {
//here locals are printed without getISO3Country() method
System.out.println(lclarray[i]);
}
}
}
输出结果为:
The first 5 locales installed in runtime environment are :-
ar_AE
ar_JO
ar_SY
hr_HR
fr_BE
6 示例3
package com.yiidian;
/**
* 一点教程网: http://www.yiidian.com
*/
/**
* java.util.Calendar getAvailableLocales()方法的例子
*/
import java.util.Calendar;
import java.util.Locale;
public class JavaCalendargetavailablelocalsExample3 {
public static void main(String[] args) {
Locale[] alllocal = Calendar.getAvailableLocales();
// print list of all available locals
for(Locale locale:alllocal){
System.out.println(locale);
}
}
}
输出结果为:
ar_AE
ar_JO
ar_SY
hr_HR
fr_BE
es_PA
mt_MT
es_VE
bg
zh_TW
it
ko
uk
lv
da_DK
es_PR
vi_VN
en_US
//all other available locales on java runtime environment will also be printed as output
热门文章
优秀文章