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

Output:

Locale: english_IN
Name: english (India)

Example 2

Output:

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

Example 3

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

Output:

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

Example 5

Output:

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