CHINA ITALIAN SIMPLIFIED_CHINESE
CHINESE ITALY TAIWAN
ENGLISH JAPAN TRADITIONAL_CHINESE
FRANCE JAPANESE UK
FRENCH KOREA US
For example, the expressionLocale.CANADArepresents theLocaleobject for Canada.
The constructors forLocaleare
Locale(Stringlanguage)
Locale(Stringlanguage, Stringcountry)
Locale(Stringlanguage, Stringcountry, Stringdata)
These constructors build aLocaleobject to represent a specificlanguageand in the case
of the last two,country.These values must contain ISO-standard language and country codes.
Auxiliary browser and vendor-specific information can be provided indata.
Localedefines several methods. One of the most important issetDefault( ), shown here:
static void setDefault(LocalelocaleObj)
This sets the default locale to that specified bylocaleObj.
Some other interesting methods are the following:
final String getDisplayCountry( )
final String getDisplayLanguage( )
final String getDisplayName( )
These return human-readable strings that can be used to display the name of the country,
the name of the language, and the complete description of the locale.
The default locale can be obtained usinggetDefault( ), shown here:
static Locale getDefault( )
CalendarandGregorianCalendarare examples of classes that operate in a locale-
sensitive manner.DateFormatandSimpleDateFormatalso depend on the locale.
Random
TheRandomclass is a generator of pseudorandom numbers. These are calledpseudorandom
numbers because they are simply uniformly distributed sequences.Randomdefines the
following constructors:
Random( )
Random(longseed)
The first version creates a number generator that uses the current time as the starting, orseed,
value. The second form allows you to specify a seed value manually.
516 Part II: The Java Library