- Java.util 包类
- Java.util - 首页
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util 包扩展
- Java.util - 接口
- Java.util - 异常
- Java.util - 枚举
- Java.util 有用资源
- Java.util - 有用资源
- Java.util - 讨论
Java Locale getDisplayCountry() 方法
描述
Java Locale getDisplayCountry() 方法返回适合显示给用户的区域设置国家/地区的名称。
声明
以下是 java.util.Locale.getDisplayCountry() 方法的声明
public final String getDisplayCountry()
参数
无
返回值
此方法返回适合该区域设置的国家/地区的名称。
异常
无
Java Locale getDisplayCountry(Locale inLocale) 方法
描述
Java Locale getDisplayCountry(Locale inLocale) 方法返回适合显示给用户的区域设置国家/地区的名称。如果可能,返回的名称将根据 inLocale 进行本地化。
声明
以下是 java.util.Locale.getDisplayCountry() 方法的声明
public String getDisplayCountry(Locale inLocale)
参数
无
返回值
此方法返回适合给定区域设置的国家/地区的名称。
异常
NullPointerException - 如果 inLocale 为 null
获取美国区域设置的显示国家/地区示例
以下示例显示了 Java Locale getDisplayCountry() 方法的使用。我们正在创建一个美国区域设置,然后检索并打印其国家/地区。
package com.tutorialspoint;
import java.util.Locale;
public class LocaleDemo {
public static void main(String[] args) {
// create a new locale
Locale locale = Locale.US;
// print this locale
System.out.println("Locale1:" + locale);
// print the country of this locale
System.out.println("Country:" + locale.getDisplayCountry());
}
}
输出
让我们编译并运行上述程序,这将产生以下结果:
Locale1:en_US Country:United States
获取加拿大区域设置的显示国家/地区示例
以下示例显示了 Java Locale getDisplayCountry() 方法的使用。我们正在创建一个加拿大区域设置,然后检索并打印其国家/地区。
package com.tutorialspoint;
import java.util.Locale;
public class LocaleDemo {
public static void main(String[] args) {
// create a new locale
Locale locale = Locale.CANADA;
// print this locale
System.out.println("Locale1:" + locale);
// print the country of this locale
System.out.println("Country:" + locale.getDisplayCountry());
}
}
输出
让我们编译并运行上述程序,这将产生以下结果:
Locale1:en_CA Country:Canada
获取法国区域设置的显示国家/地区示例
以下示例显示了 Java Locale getDisplayCountry(Locale) 方法的使用。我们正在创建一个法国区域设置,然后使用德语区域设置检索并打印其国家/地区。
package com.tutorialspoint;
import java.util.Locale;
public class LocaleDemo {
public static void main(String[] args) {
// create a new locale
Locale locale = Locale.FRANCE;
// print this locale
System.out.println("Locale1:" + locale);
// print the country of this locale
System.out.println("Country:" + locale.getDisplayCountry());
System.out.println("Country:" + locale.getDisplayCountry(Locale.GERMANY));
}
}
输出
让我们编译并运行上述程序,这将产生以下结果:
Locale1:fr_FR Country:France Country:Frankreich
java_util_locale.htm
广告