java.util.Locale.getDisplayCountry()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中java.util.Locale.getDisplayCountry()方法的一些代码示例,展示了Locale.getDisplayCountry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Locale.getDisplayCountry()方法的具体详情如下:
包路径:java.util.Locale
类名称:Locale
方法名:getDisplayCountry

Locale.getDisplayCountry介绍

[英]Equivalent to getDisplayCountry(Locale.getDefault()).
[中]等效于getDisplayCountry(Locale.getDefault())。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Equivalent to {@code getDisplayCountry(Locale.getDefault())}.
 */
public final String getDisplayCountry() {
  return getDisplayCountry(getDefault());
}

代码示例来源:origin: stackoverflow.com

Locale loc = new Locale("","NL");
loc.getDisplayCountry();

代码示例来源:origin: stackoverflow.com

Locale l = new Locale("", "NL");
String country = l.getDisplayCountry();

代码示例来源:origin: stackoverflow.com

Locale l = new Locale("", "CH");
System.out.println(l.getDisplayCountry());

代码示例来源:origin: remkop/picocli

@Override
  public void run() {
    for (String code : countryCodes) {
      System.out.println(String.format("%s: %s", code.toUpperCase(), new Locale("", code).getDisplayCountry()));
    }
  }
}

代码示例来源:origin: com.h2database/h2

/**
 * Get the collation name.
 *
 * @param l the locale
 * @return the name of the collation
 */
public static String getName(Locale l) {
  Locale english = Locale.ENGLISH;
  String name = l.getDisplayLanguage(english) + ' ' +
      l.getDisplayCountry(english) + ' ' + l.getVariant();
  name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_'));
  return name;
}

代码示例来源:origin: stackoverflow.com

String[] locales = Locale.getISOCountries();

for (String countryCode : locales) {

  Locale obj = new Locale("", countryCode);

  System.out.println("Country Code = " + obj.getCountry() 
    + ", Country Name = " + obj.getDisplayCountry());

}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws InterruptedException {
  Map<String, String> countries = new HashMap<>();
  for (String iso : Locale.getISOCountries()) {
    Locale l = new Locale("", iso);
    countries.put(l.getDisplayCountry(), iso);
  }

  System.out.println(countries.get("Switzerland"));
  System.out.println(countries.get("Andorra"));
  System.out.println(countries.get("Japan"));
}

代码示例来源:origin: stackoverflow.com

Locale[] locale = Locale.getAvailableLocales();
ArrayList<String> countries = new ArrayList<String>();
String country;
for( Locale loc : locale ){
  country = loc.getDisplayCountry();
  if( country.length() > 0 && !countries.contains(country) ){
    countries.add( country );
  }
}
Collections.sort(countries, String.CASE_INSENSITIVE_ORDER);

Spinner citizenship = (Spinner)findViewById(R.id.input_citizenship);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, countries);
citizenship.setAdapter(adapter);

代码示例来源:origin: lealone/Lealone

/**
 * Get the collation name.
 *
 * @param l the locale
 * @return the name of the collation
 */
public static String getName(Locale l) {
  Locale english = Locale.ENGLISH;
  String name = l.getDisplayLanguage(english) + ' ' + l.getDisplayCountry(english) + ' ' + l.getVariant();
  name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_'));
  return name;
}

代码示例来源:origin: stackoverflow.com

import java.util.*;

class Countries {

  public static void main(String[] args) {
    Locale[] locales = Locale.getAvailableLocales();
    ArrayList<String> countries = new ArrayList<String>();
    for (Locale locale : locales) {
      String country = locale.getDisplayCountry();
      if (country.trim().length()>0 && !countries.contains(country)) {
        countries.add(country);
      }
    }
    Collections.sort(countries);
    for (String country : countries) {
      System.out.println(country);
    }
    System.out.println( "# countries found: " + countries.size());
  }
}

代码示例来源:origin: javamelody/javamelody

public String getCountryDisplay() {
  final String myCountry = getCountry();
  if (myCountry == null) {
    return null;
  }
  // "fr" est sans conséquence
  return new Locale("fr", myCountry).getDisplayCountry(I18N.getCurrentLocale());
}

代码示例来源:origin: jphp-group/jphp

@Signature(@Arg(value = "locale", nativeType = WrapLocale.class, optional = @Optional("null")))
public Memory getDisplayCountry(Environment env, Memory... args) {
  return StringMemory.valueOf(args[0].isNull()
      ? locale.getDisplayCountry()
      : locale.getDisplayCountry(args[0].toObject(WrapLocale.class).locale)
  );
}

代码示例来源:origin: stackoverflow.com

Locale loc = new Locale("", ssid);
return loc.getDisplayCountry().trim();

代码示例来源:origin: robovm/robovm

buffer.append(" (");
String displayCountry = getDisplayCountry(locale);
buffer.append(displayCountry.isEmpty() ? countryCode : displayCountry);
++count;

代码示例来源:origin: shopizer-ecommerce/shopizer

private void createCountries() throws ServiceException {
  LOGGER.info(String.format("%s : Populating Countries ", name));
  List<Language> languages = languageService.list();
  for(String code : SchemaConstant.COUNTRY_ISO_CODE) {
    Locale locale = SchemaConstant.LOCALES.get(code);
    if (locale != null) {
      Country country = new Country(code);
      countryService.create(country);
      
      for (Language language : languages) {
        String name = locale.getDisplayCountry(new Locale(language.getCode()));
        //byte[] ptext = value.getBytes(Constants.ISO_8859_1); 
        //String name = new String(ptext, Constants.UTF_8); 
        CountryDescription description = new CountryDescription(language, name);
        countryService.addCountryDescription(country, description);
      }
    }
  }
}

代码示例来源:origin: stackoverflow.com

+ defaultLocale.getLanguage() + "_" + defaultLocale.getCountry()
    + " (" + defaultLocale.getDisplayLanguage()
    + "," + defaultLocale.getDisplayCountry() + ")");
System.out.println("  now = " + nowInMillis + " [ms] or "
    + createDateFormat().format(now));

代码示例来源:origin: stackoverflow.com

"</td><td>" +
prefix +
locale.getDisplayCountry() +
suffix +
"</td><td>" +

代码示例来源:origin: stackoverflow.com

public String[] getOtherCountries() {
  Set<String> countries = new HashSet<String>();
  Set<Object> keys = supportedLanguages.keySet();
  for (Object key : keys) {
    Locale other = (Locale) supportedLanguages.get(key);
    if (other != requestLocale) {
      countries.add(other.getDisplayCountry(requestLocale));
    }
  }

  return countries.toArray(new String[0]);
}

代码示例来源:origin: matyb/java-koans

@Koan
public void getCountryInformation() {
  Locale locBR = new Locale("pt", "BR");
  assertEquals(locBR.getDisplayCountry(), __);
  assertEquals(locBR.getDisplayCountry(locBR), __);
  Locale locCH = new Locale("it", "CH");
  assertEquals(locCH.getDisplayCountry(), __);
  assertEquals(locCH.getDisplayCountry(locCH), __);
  assertEquals(locCH.getDisplayCountry(new Locale("de", "CH")), __);
}

相关文章