+1 vote
in JAVA by
What is Locale?

1 Answer

0 votes
by

A Locale object represents a specific geographical, political, or cultural region. This object can be used to get the locale-specific information such as country name, language, variant, etc.

import java.util.*;  

public class LocaleExample {  

public static void main(String[] args) {  

Locale locale=Locale.getDefault();  

//Locale locale=new Locale("fr","fr");//for the specific locale  

  

System.out.println(locale.getDisplayCountry());  

System.out.println(locale.getDisplayLanguage());  

System.out.println(locale.getDisplayName());  

System.out.println(locale.getISO3Country());  

System.out.println(locale.getISO3Language());  

System.out.println(locale.getLanguage());  

System.out.println(locale.getCountry());  

      

}  

}  

Output:

  • United States
  • English
  • English (United States)
  • USA
  • eng
  • en
  • US

Related questions

+2 votes
asked May 13, 2021 in JAVA by rajeshsharma
+2 votes
asked May 13, 2021 in JAVA by rajeshsharma
...