getISO3Country():java.util.Locale.getISO3Country()显示Locale country的3个字母缩写。
句法 :
public String getISO3Country()
参数:
----
返回:
-------------
// Java Program illustrating the use of methods :
// getDisplayCountry(), getCountry(), equal(), clone(),
// getAvailableLocales(), getDefault(),
// getDisplayLanguage(Locale in), getDisplayLanguage(),
// getDisplayName(Locale in), getDisplayName(),
// getISO3Country()
import java.util.*;
public class NewClass
{
public static void main(String[] args)
{
// Creting a new Locale
Locale geek1 = new Locale("English", "IN");
// Use of getDefault() :
Locale geek2 = Locale.getDefault();
System.out.println("Locale name : " + geek1);
System.out.println("Locale name Default : " + geek2);
// Use of getDisplayCountry() :
System.out.println("\nCountry Name : "
+ geek1.getDisplayCountry());
// Use of getCountry() :
System.out.println("Country Name ISO 3166 2-letter code : "
+ geek1.getCountry());
// Use of equal() :
System.out.println("\nIs geek1 equals geek2 : "
+ geek1.equals(geek2));
// clone() : geek3 is a clone of geek2
Locale geek3 = (Locale) geek2.clone();
// Locale : geek3
System.out.println("Locale geek3 same as geek2 : "
+ geek3);
// Use of getAvailableLocales()
Locale[] geek4 = Locale.getAvailableLocales();
// We are not printing all the locales.
System.out.println("\nInstalled locales are : ");
for (int i = 1; i < geek4.length/10; i++)
System.out.println(i + ":" + geek4[i]);
// Use of getDisplayLanguage() :
System.out.println("\ngeek2 Language : "
+ geek2.getDisplayLanguage());
// Use of getDisplayLanguage(Locale in) :
System.out.println("Language of in Locale : "
+ geek1.getDisplayLanguage(new Locale("France", "French")));
// Use of getDisplayName :
System.out.println("\nUse of getDisplayName : "
+ geek1.getDisplayName());
// Use of getDisplayName(Locale in) :
System.out.println("Name of in Locale : "
+ geek2.getDisplayName(new Locale("English", "english")));
// Use of getISO3Country() :
System.out.println("\nISO3 Country Name of geek3 : "
+ geek3.getISO3Country());
}
}
输出:
Locale name : english_IN
Locale name Default : en_US
Country Name : India
Country Name ISO 3166 2-letter code : IN
Is geek1 equals geek2 : false
Locale geek3 same as geek2 : en_US
Installed locales are :
1:ar_AE
2:ar_JO
3:ar_SY
4:hr_HR
5:fr_BE
6:es_PA
7:mt_MT
8:es_VE
9:bg
10:zh_TW
11:it
12:ko
13:uk
14:lv
15:da_DK
geek2 Language : English
Language of in Locale : english
Use of getDisplayName : english (India)
Name of in Locale : English (United States)
ISO3 Country Name of geek3 : USA