Listing all available Locales

This section shows you how to list all the available locales installed with the software development kit.

Listing all available Locales


Locale is the class of java.util.*; package. This class represents the geographical, political and cultural region. Every tasks which requires to perform the operation is called local-sensitive. In this world, each places have it's own country name, language name etc. these can be determined by the object of the Locale class.

This section shows you how to list all the available locales installed with the software development kit. The given program in this section displays all the available language code, country code and full country name. Some following method and APIs which have used in the program for completion the task these are explained as follows:

Above method return a array of available locales which are installed with your software development kit.

Above method returns the two character 'language code' for the specific locale. You can display the full language name by using the getDisplayLanguage() method of the Locale class.

Above method returns the two character country code for the specific locale. If you want to display the full country name then you can use the getDisplayCountry() method of Locale class.

Above method display the full description about the created locale that means the specific geographical or political or the cultural region.

Here is the code of the program:

import java.util.*;

public class Locales{
  public static void main(String[] args){
  Locale[] locales = Locale.getAvailableLocales();
  for(int i = 0; i < locales.length; i++){
  String language = locales[i].getLanguage();
  String country = locales[i].getCountry();
  String locale_name = locales[i].getDisplayName();
  System.out.println(i + ": " + language + ", " + country + ", 
+ locale_name);

Download this example.

Share on Google+Share on Google+

Listing all available Locales

Posted on: April 16, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Listing all available Locales   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
October 7, 2012

I have litle confusion with Locale class in java.util package that is how to operate with Array in this class and for which purpose.... reply soon