A Quick Example |
ALocale
object identifies a particular language and country. The following statement defines a Locale for which the language is English and the country is the United States:The next example createsaLocale = new Locale("en","US");Locale
objects for the French language in Canada and in France:We want to keep our sample program flexible, so instead of hardcoding the the language and country codes, we'll get them from the command line at runtime:caLocale = new Locale("fr","CA"); frLocale = new Locale("fr","FR");String language = new String(args[0]); String country = new String(args[1]); currentLocale = new Locale(language, country);Locale
objects are only identifiers. After defining aLocale
, you pass it to other objects that perform useful tasks, such as formatting dates and numbers. These objects are called locale-sensitive, because their behavior varies according toLocale
. AResourceBundle
is an example of a locale-sensitive object.
A Quick Example |