Javatpoint Logo
Javatpoint Logo

Java Locale class

The Java Locale class object represents a specific geographic, cultural, or political region. It is a mechanism to for identifying objects, not a container for the objects themselves. A Locale object logically consists of the fields like languages, script, country, variant, extensions.

Syntax

Example 1

Test it Now

Output:

Locale: en_INDIA
Language: English
Country Name: INDIA
HashCode for this locale: -2034354048

Example 2

Test it Now

Output:

Locale1 name: english_US_WIN
String representation of Locale1: english_US_WIN
Locale2: fr_FRANCE_WIN
String representation of Locale2: fr_FRANCE_WIN

Java Locale methods

Below is the list of all Java Locale methods:

Method Description
clone() It is used to create a copy of this locale
hashCode() It is used to return a hash code for this locale.
getAvailableLocales() It is used to return an array of all installed locales.
getCountry() It returns the country/region code for this locale.
getLanguage() It is used to return the language code of this Locale
getDefault() It is used to get the current value of the default locale for this instance of the JVM.
setDefault() It used to set the default locale for this instance of the JVM(Java Virtual Machine).
getDisplayCountry() It returns a name for the locale's country that is appropriate for display to the user.
getDisplayCountry(Locale inLocale) It returns a name for the locale's country that is appropriate for display to the user.
getDisplayLanguage() It returns the name for the language of locale that is appropriate for display to the user.
getDisplayLanguage(Locale inLocale) It returns a name for the locale's language that is appropriate for display to the user.
getDisplayName() It is used to return a name for the locale that is appropriate for display to the user.
getDisplayName(Locale inLocale) It is used to return a name for the locale that is appropriate for display to the user.
getDisplayVariant() It is used to return a name for the locale's variant code that is appropriate for display to the user.
getDisplayVariant(Locale inLocale) It is used to return a name for the locale's variant code that is appropriate for display to the user.
getISO3Country() It returns a three-letter abbreviation for this locale's country.
getISO3Language() It returns a three-letter abbreviation for this locale's language.
getISOLanguages() It returns a list of all 2-letter language codes defined in ISO 639.
getISOCountries() It returns a list of all 2-letter country codes defined in ISO 639.
getVariant() It is used to return the variant code for this locale.
toString() It is used to return a string representation of this Locale object, consisting of language, country, variant, script, and extensions.
Next TopicJava Locale




Help Others, Please Share

facebook twitter pinterest