Javatpoint Logo
Javatpoint Logo

Java Locale getDisplayName() method

The getDisplayName() method of Locale class is used to return a name for the locale that is appropriate for display to the user. This will be the value returned by getDisplayScript(), getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string.

Syntax

Parameter

NA

Return

This method does not return a value.

Example 1

Test it Now

Output:

Locale: english_IN
Name: english (India)

Example 2

Test it Now

Output:

Locale1: english_IN
Locale2: german_AU
Name of Locale1: english (India)
Name of Locale2: german (Australia)

Example 3

Test it Now

Output:

Locale1: spanish_EC
Locale2: french_BE
Locale3: french_BE
Name of Locale1: spanish (Ecuador)
Name of Locale2: french (Belgium)
Name of Locale3: german (Australia)

Java Locale getDisplayName(Locale inLocale) method

The getDisplayName(Locale inLocale) method of Locale class is used to return a name for the locale that is appropriate for display to the user. This will be the value returned by getDisplayScript(), getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string.

Syntax

Throws

NullPointerException: This exception will throw if inLocale is null.

Example 4

Test it Now

Output:

Locale: english_IN
Name of in Locale: english (India)

Example 5

Test it Now

Output:

Locale1: english_IN
Locale2: spanish_EC
Name of in Locale1: english (India)
Name of in Locale2: spanish (Ecuador)

Next TopicJava Locale




Help Others, Please Share

facebook twitter pinterest