Calendar and display name

TypeMetodSummary
static Locale[]getAvailableLocales()Returns an array of all locales for which the getInstance methods of this class can return localized instances.
StringgetDisplayName(int field, int style, Locale locale)Returns the string representation of the calendar field value in the given style and locale.
Map<String,Integer>getDisplayNames(int field, int style, Locale locale)Returns a Map containing all names of the calendar field in the given style and locale and their corresponding field values.

The following code displays all locales from Calendar class:


import java.util.Calendar;
import java.util.Locale;

public class Main{
  public static void main(String[] argv){
    Locale[] locales = Calendar.getAvailableLocales();
    for(Locale l: locales){
      System.out.println(l.getDisplayCountry());
    }
  }
}

The output:


Japan
Peru

Japan
Panama
Bosnia and Herzegovina

Guatemala
United Arab Emirates
Norway
Albania

Iraq
Yemen

Portugal
Cyprus
Qatar
Macedonia

Switzerland
United States
Finland


Malta
Slovenia
Slovakia

Turkey


Saudi Arabia

United Kingdom
Serbia and Montenegro


New Zealand
Norway
Lithuania
Nicaragua

Ireland
Belgium
Spain
Lebanon

Canada
Estonia
Kuwait
Serbia
United States
Mexico
Sudan
Indonesia


Uruguay
Latvia

Brazil
Syria


Dominican Republic
Switzerland
India
Venezuela
Bahrain
Philippines
Tunisia

Austria

Netherlands
Ecuador
Taiwan
Jordan

Iceland
Colombia
Costa Rica
Chile
Egypt
South Africa
Thailand
Greece
Italy

Hungary

Ireland
Ukraine
Poland
Luxembourg
Belgium
India
Spain
Morocco
Bolivia
Australia

Singapore


El Salvador
Russia
South Korea

Algeria
Vietnam
Montenegro

Libya

China
Belarus
Hong Kong

Israel
Bulgaria

Malta
Paraguay

France
Czech Republic
Switzerland
Romania
Puerto Rico
Canada
Germany

Luxembourg

Argentina

Malaysia
Croatia
Singapore



Oman

Thailand


Sweden
Denmark
Honduras
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.