Java DateFormat: getAvailableLocales() Example.

Java DateFormat: getAvailableLocales() Example.


Posted in : Core Java Posted on : December 3, 2010 at 4:38 PM Comments : [ 0 ]

Java DateFormat: getAvailableLocales() Example.

Java DateFormat: getAvailableLocales() Example.

In this section, you will see how to display all available locale. The getAvailableLocales() is a method of DateFormat class in java.

Syntax is : public static Locale[] getAvailableLocales()
Method returns an array of all locales for which the getInstance() methods of this class can return localized instances. The returned array
represents the union of locales supported by the Java runtime and by installed DateFormatProvider implementations. It must contain at
least a Locale instance equal to Locale.US.

Code:
GetAvailablesLocale .java
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

public class GetAvailablesLocale {
public static void main(String[] args) {
	Date obDate = new Date();
	DateFormat obFormat = DateFormat.getInstance();
	Locale[] locales = obFormat.getAvailableLocales();
	for (int i = 0; i < locales.length; i++) {
	System.out.println("Available locales : " + locales[i]);
	}
    }
}
Output
Available locales : ja_JP
Available locales : es_PE
Available locales : en
Available locales : ja_JP_JP
Available locales : es_PA
Available locales : sr_BA
Available locales : mk
Available locales : es_GT
Available locales : ar_AE
Available locales : no_NO
Available locales : sq_AL
Available locales : bg
-------------------------

Download this code.
Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics