Locale: getDisplayCountry() : Locale « java.util « Java by API






Locale: getDisplayCountry()

 
/*
 * 
The Date for United States:
  In FULL is Tuesday, May 9, 2006
  In LONG is May 9, 2006
  In MEDIUM is May 9, 2006
  In SHORT is 5/9/06

The Date for United Kingdom:
  In FULL is 09 May 2006
  In LONG is 09 May 2006
  In MEDIUM is 09-May-2006
  In SHORT is 09/05/06

The Date for Germany:
  In FULL is Dienstag, 9. Mai 2006
  In LONG is 9. Mai 2006
  In MEDIUM is 09.05.2006
  In SHORT is 09.05.06

The Date for France:
  In FULL is mardi 9 mai 2006
  In LONG is 9 mai 2006
  In MEDIUM is 9 mai 2006
  In SHORT is 09/05/06

 * */

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

public class MainClass {

  public static void main(String[] args) {
    Date today = new Date();
    Locale[] locales = { Locale.US, Locale.UK, Locale.GERMANY, Locale.FRANCE };
    
    int[] styles = { DateFormat.FULL, DateFormat.LONG, DateFormat.MEDIUM,
        DateFormat.SHORT };
        
    DateFormat fmt;
    String[] styleText = { "FULL", "LONG", "MEDIUM", "SHORT" };

    // Output the date for each local in four styles
    for (int i = 0; i < locales.length; i++) {
      System.out.println("\nThe Date for " + locales[i].getDisplayCountry()
          + ":");
      for (int j = 0; j < styles.length; j++) {
        fmt = DateFormat.getDateInstance(styles[j], locales[i]);
        System.out.println("\tIn " + styleText[j] + " is " + fmt.format(today));
      }
    }
  }
}

           
         
  








Related examples in the same category

1.Locale.CANADA_FRENCH
2.Locale.GERMANY
3.Locale.ITALY
4.Locale.JAPAN
5.Locale.KOREA
6.Locale.TAIWAN
7.Locale.UK
8.Locale.US
9.new Locale(String language, String country, String variant)
10.Locale: getDefault()
11.Locale: getDisplayCountry(Locale inLocale)
12.Locale: getDisplayLanguage()
13.Locale: getDisplayName()
14.Locale: getDisplayName(Locale inLocale)
15.Locale: getDisplayVariant()
16.Locale: getDisplayVariant(Locale inLocale)
17.Locale: getISOCountries()
18.Locale.getISOLanguages()
19.Locale: setDefault(Locale newLocale)