A Locale 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:
aLocale = new Locale("en","US");
The next example creates Locale objects
for the French language in
Canada and in France:
caLocale = new Locale("fr","CA");
frLocale = new Locale("fr","FR");
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:
String language = new String(args[0]);
String country = new String(args[1]);
currentLocale = new Locale(language, country);
Locale objects are only identifiers.
After defining a Locale, 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 to Locale.
A ResourceBundle is an example of a locale-sensitive
object.