Java Locale getDisplayLanguage() Example

Locale class getDisplayLanguage() method example. This example shows you how to use getDisplayLanguage() method.


Syntax is : public String getDisplayLanguage(Locale inLocale)
Method returns a name for the locale's language and If possible, the name returned will be localized according to inLocale and if the locale doesn't specify a country, this function returns the empty string.

Here is the code.

/**
 * @(#) GetDisplayLanguage1Locale.java
 * A class representing use of method getDisplayLanguage() of Locale class
 in java.util Package.
 * @Version  26-May-2008
 @author   Rose India Team
 */
import java.util.*;

class GetDisplayLanguage1Locale {
    public static void mainString args[] ){

     /* Create object of Locale class using contructor 
           Locale(String language, String country) */
         Locale obj1 = new Locale("EN","US");
       Locale obj2 = new Locale("CH","CHINA");
     System.out.println("object obj1 of Locale class is : "+obj1);
       System.out.println("object obj2 of Locale class is : "+obj2);
     // getDisplayLanguage() method call.
         String langauge = obj1.getDisplayLanguage(obj2);
     System.out.println("Language for object obj1 : " + langauge);
     langauge = obj2.getDisplayLanguage(obj1);
     System.out.println("Language for object obj2 : " + langauge);
  }
}

Output of the program.
object objLocale1 of Locale class is : en_US
object objLocale2 of Locale class is : ch_CHINA
Language for object obj1 : English
Language for object obj2 : Chamorro

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US