getDisplayCountry()

String getDisplayCountry()
Returns a name for the locale's country.
 
/*
 * 
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));
      }
    }
  }
}
  
Home 
  Java Book 
    Essential Classes  

Locale:
  1. Locale class
  2. Locale.ITALY
  3. Use Locale with DateFormat
  4. new Locale(String language, String country, String variant)
  5. getDefault()
  6. getDisplayCountry()
  7. getDisplayCountry(Locale inLocale)
  8. getDisplayLanguage()
  9. getDisplayName()
  10. getDisplayVariant()
  11. getISOCountries()
  12. getISOLanguages()
  13. setDefault(Locale newLocale)