Java-i18n-locale-details

提供:Dev Guides
移動先:案内検索

Java内部化-ロケールの詳細

この例では、デフォルトのロケールを取得し、その詳細を出力します。 次に、「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 States
English
English (United States)
USA
eng
en
US

fr Locale Properties:

France
French
French (France)
FRA
fra
fr
FR

link:/cgi-bin/printpage.cgi [__印刷]