Java Locale getDisplayVariant() method

The getDisplayVaiant() method of Java Locale class is used to return a name for the locale's variant code that is appropriate for display to the user. This method returns the empty string if the locale doesn't specify a variant code.

Syntax

Parameter

NA

Example 1

Output:

Locale: english_IN_IND
Variant: IND

Example 2

Output:

Locale1: english_IN_IND
Locale2: english_IN_IND
Variant of locale1: IND
Variant of locale2: WIN

Example 3

Output:

Locale1: english_IN
Variant of locale1:

Java Locale getDisplayVariant() method

The getDisplayVariant(Locale inLocale) method of Java Locale class is used to return a name for the locale's variant code that is appropriate for display to the user. This method returns the empty string if the locale doesn?t specify a variant code.

Syntax

Throws

NullPointerException - This exception will throw if inLocale is null.

Example 4

Output:

Locale1: english_IN_IND
Name of in Locale: IND

Example 5

Output:

Locale1: english_IN_IND
Locale2: french_EC_WIN
Name of in Locale1: IND
Name of in Locale2: WIN