The i18n Cookbook - recipies for a global society

  • java cookbook
  • about the author
Home › Java Internationalization Cookbook › Locales

Java Cookbook

  • Java Internationalization Cookbook
    • Locales
      • How to make a Locale object using language and country arguments
      • How to use a static constant to retrieve a common locale
      • How to get an array of available lLocales
      • Get all ISO language and country codes
      • Get localized display names
      • Create an ICU4J ULocale
    • Dates and Times
    • Numerical Systems
    • Misc
    • Resource Bundles
    • Unicode, Transliteration, and Charactersets

How to use a static constant to retrieve a common locale

Problem:

You want to use a common locale without having to create a new locale object.

Solution:

Many common locales are stored in static constants within the Locale class for convenience. To retrieve one simply use the locale name attached to the class name. To get a Japanese locale: Locale myLocale = Locale.JAPANESE; To get a Locale for the country of Japan: Locale myLocale = Locale.JAPAN; To get a simplified Chinese Locale: Locale myLocale = Locale.SIMPLIFIED_CHINESE; The available constants as of 1.5 are:

  • CANADA
  • CANADA_FRENCH
  • CHINA
  • CHINESE
  • ENGLISH
  • FRANCE
  • FRENCH
  • GERMAN
  • GERMANY
  • ITALIAN
  • ITALY
  • JAPAN
  • JAPANESE
  • KOREA
  • KOREAN
  • PRC
  • SIMPLIFIED_CHINESE
  • TAIWAN
  • TRADITIONAL_CHINESE
  • UK
  • US
‹ How to make a Locale object using language and country arguments up How to get an array of available lLocales ›
  • Locale
  • static locale
  • Printer-friendly version

If you are testing any of these recipes in Eclipse and the characters are not displaying correctly in your console visit http://i18ncookbook.com/eclipse_settings.

This site is ad supported.  I hope you find something among our sponsors worth clicking. ;)

i18n search

Google
Custom Search

Search

Tags in Tags

calendar date icu4j Java Locale number format numberformat parse spellout timezone transliteration transliterator
more tags

User login

  • Create new account
  • Request new password
  • java cookbook
  • about the author