

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Importance of a Locale class in Java?
A Locale class is used to perform locale operations and supply locale information to the user. A Locale is defined as a set of parameters that represents a geographical location or place where some operation occurs. The important methods of Locale class are getAvailableLocales(), getCountry(), getDefault(), getDisplayLanguage(), getDisplayCountry(), getUnicodeLocaleKeys() etc.
The Locale class uses the following constructors:
- Locale(String L): Initializes locale from the language code passed as an argument.
- Locale(String L, String C): Initializes locale from the language, country code passed as arguments.
- Locale(String L, String C, String V): Initializes locale from the language, country, variant passed as arguments.
Syntax
public final class Locale extends Object implements Cloneable, Serializable
Example
import java.text.SimpleDateFormat; import java.util.Locale; public class LocaleTest { public static void main(String[] args) { Locale loc[] = SimpleDateFormat.getAvailableLocales(); for (int i=1; i <= 15; i++) { System.out.printf("\n%s (%s) ", loc[i].getDisplayName(), loc[i].toString()); } } }
Output
Arabic (United Arab Emirates) (ar_AE) Arabic (Jordan) (ar_JO) Arabic (Syria) (ar_SY) Croatian (Croatia) (hr_HR) French (Belgium) (fr_BE) Spanish (Panama) (es_PA) Maltese (Malta) (mt_MT) Spanish (Venezuela) (es_VE) Bulgarian (bg) Chinese (Taiwan) (zh_TW) Italian (it) Korean (ko) Ukrainian (uk) Latvian (lv) Danish (Denmark) (da_DK)
- Related Questions & Answers
- What is a Locale class in Java?
- Importance of a Dictionary class in Java?
- Importance of StringReader class in Java?
- Importance of MethodHandles class in Java 9?
- What is the importance of a SwingWorker class in Java?
- What is the importance of a Cursor class in Java?
- What is the importance of SwingUtilities class in Java?
- What is the importance of JViewport class in Java?
- What is the importance of JSeparator class in Java?
- What is the importance of Runtime class in Java?
- What is the importance of Boolean class in Java?
- What is the importance of the Container class in Java?
- What is the importance of the GridBagConstraints class in Java?
- What is the importance of the CardLayout class in Java?
- Importance of a JSONTokener in Java?
Advertisements