开发手册 欢迎您!
软件开发者资料库

Java内部化 - 区域设置详细信息

Java内部化区域设置详细信息 - 从简单和简单的步骤学习Java内部化,从基本概念到高级概念,包括概述,环境设置,区域设置,区域设置详细信息,显示语言,ResourceBundle,NumberFormat,格式货币,格式百分比,设置最小/最大精度,设置舍入模式,解析数字,DecimalFormat,格式数字,特定于区域设置的DecimalFormat,DecimalFormatSymbols,分组数字,DateFormat,格式化日期,格式化时间,格式化日期和时间,SimpleDateFormat,解析日期,特定于区域设置的SimpleDateFormat,DateFormatSymbols,UTC,转换时间区域,可用时区

在此示例中,我们将获取默认语言环境并打印其详细信息.然后为"fr"创建一个区域设置并打印其详细信息.

I18NTester.java

import java.util.Locale;public class I18NTester {   public static void main(String[] args) {      Locale locale =Locale.getDefault();        System.out.println("Default Locale Properties:\n");      System.out.println(locale.getDisplayCountry());        System.out.println(locale.getDisplayLanguage());        System.out.println(locale.getDisplayName());        System.out.println(locale.getISO3Country());        System.out.println(locale.getISO3Language());        System.out.println(locale.getLanguage());        System.out.println(locale.getCountry());        Locale frenchLocale = new Locale("fr","fr");      System.out.println("\nfr Locale Properties:\n");      System.out.println(frenchLocale.getDisplayCountry());        System.out.println(frenchLocale.getDisplayLanguage());        System.out.println(frenchLocale.getDisplayName());        System.out.println(frenchLocale.getISO3Country());        System.out.println(frenchLocale.getISO3Language());        System.out.println(frenchLocale.getLanguage());        System.out.println(frenchLocale.getCountry());     }}

输出

它将打印以下结果.

Default Locale Properties:United StatesEnglishEnglish (United States)USAengenUSfr Locale Properties:FranceFrenchFrench (France)FRAfrafrFR