Java Utility Library

Java Locale - getDisplayLanguage() Method



The java.util.Locale.getDisplayLanguage() method returns a name for the locale's language that is appropriate for display to the user.

Syntax

public final String getDisplayLanguage()

Parameters

No parameter is required.

Return Value

Returns the name of the display language.

Exception

NA

Example:

In the example below, the java.util.Locale.getDisplayLanguage() method is used to get the name of the given locale's language.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a locale
    Locale loc = new Locale("EN", "UK");

    //printing the locale
    System.out.println("loc is: " + loc);

    //printing the name of the language
    System.out.println("Language is: " + loc.getDisplayLanguage());
  }
}

The output of the above code will be:

loc is: en_UK
Language is: English

❮ Java.util - Locale