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

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

本文整理了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

  1. /**
  2. * Equivalent to {@code getDisplayCountry(Locale.getDefault())}.
  3. */
  4. public final String getDisplayCountry() {
  5. return getDisplayCountry(getDefault());
  6. }

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Get the collation name.
  3. *
  4. * @param l the locale
  5. * @return the name of the collation
  6. */
  7. public static String getName(Locale l) {
  8. Locale english = Locale.ENGLISH;
  9. String name = l.getDisplayLanguage(english) + ' ' +
  10. l.getDisplayCountry(english) + ' ' + l.getVariant();
  11. name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_'));
  12. return name;
  13. }

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

  1. String[] locales = Locale.getISOCountries();
  2. for (String countryCode : locales) {
  3. Locale obj = new Locale("", countryCode);
  4. System.out.println("Country Code = " + obj.getCountry()
  5. + ", Country Name = " + obj.getDisplayCountry());
  6. }

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

  1. public static void main(String[] args) throws InterruptedException {
  2. Map<String, String> countries = new HashMap<>();
  3. for (String iso : Locale.getISOCountries()) {
  4. Locale l = new Locale("", iso);
  5. countries.put(l.getDisplayCountry(), iso);
  6. }
  7. System.out.println(countries.get("Switzerland"));
  8. System.out.println(countries.get("Andorra"));
  9. System.out.println(countries.get("Japan"));
  10. }

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

  1. Locale[] locale = Locale.getAvailableLocales();
  2. ArrayList<String> countries = new ArrayList<String>();
  3. String country;
  4. for( Locale loc : locale ){
  5. country = loc.getDisplayCountry();
  6. if( country.length() > 0 && !countries.contains(country) ){
  7. countries.add( country );
  8. }
  9. }
  10. Collections.sort(countries, String.CASE_INSENSITIVE_ORDER);
  11. Spinner citizenship = (Spinner)findViewById(R.id.input_citizenship);
  12. ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, countries);
  13. citizenship.setAdapter(adapter);

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

  1. /**
  2. * Get the collation name.
  3. *
  4. * @param l the locale
  5. * @return the name of the collation
  6. */
  7. public static String getName(Locale l) {
  8. Locale english = Locale.ENGLISH;
  9. String name = l.getDisplayLanguage(english) + ' ' + l.getDisplayCountry(english) + ' ' + l.getVariant();
  10. name = StringUtils.toUpperEnglish(name.trim().replace(' ', '_'));
  11. return name;
  12. }

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

  1. import java.util.*;
  2. class Countries {
  3. public static void main(String[] args) {
  4. Locale[] locales = Locale.getAvailableLocales();
  5. ArrayList<String> countries = new ArrayList<String>();
  6. for (Locale locale : locales) {
  7. String country = locale.getDisplayCountry();
  8. if (country.trim().length()>0 && !countries.contains(country)) {
  9. countries.add(country);
  10. }
  11. }
  12. Collections.sort(countries);
  13. for (String country : countries) {
  14. System.out.println(country);
  15. }
  16. System.out.println( "# countries found: " + countries.size());
  17. }
  18. }

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

  1. public String getCountryDisplay() {
  2. final String myCountry = getCountry();
  3. if (myCountry == null) {
  4. return null;
  5. }
  6. // "fr" est sans conséquence
  7. return new Locale("fr", myCountry).getDisplayCountry(I18N.getCurrentLocale());
  8. }

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

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

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

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

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

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

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

  1. private void createCountries() throws ServiceException {
  2. LOGGER.info(String.format("%s : Populating Countries ", name));
  3. List<Language> languages = languageService.list();
  4. for(String code : SchemaConstant.COUNTRY_ISO_CODE) {
  5. Locale locale = SchemaConstant.LOCALES.get(code);
  6. if (locale != null) {
  7. Country country = new Country(code);
  8. countryService.create(country);
  9. for (Language language : languages) {
  10. String name = locale.getDisplayCountry(new Locale(language.getCode()));
  11. //byte[] ptext = value.getBytes(Constants.ISO_8859_1);
  12. //String name = new String(ptext, Constants.UTF_8);
  13. CountryDescription description = new CountryDescription(language, name);
  14. countryService.addCountryDescription(country, description);
  15. }
  16. }
  17. }
  18. }

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

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

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

  1. "</td><td>" +
  2. prefix +
  3. locale.getDisplayCountry() +
  4. suffix +
  5. "</td><td>" +

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

  1. public String[] getOtherCountries() {
  2. Set<String> countries = new HashSet<String>();
  3. Set<Object> keys = supportedLanguages.keySet();
  4. for (Object key : keys) {
  5. Locale other = (Locale) supportedLanguages.get(key);
  6. if (other != requestLocale) {
  7. countries.add(other.getDisplayCountry(requestLocale));
  8. }
  9. }
  10. return countries.toArray(new String[0]);
  11. }

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

  1. @Koan
  2. public void getCountryInformation() {
  3. Locale locBR = new Locale("pt", "BR");
  4. assertEquals(locBR.getDisplayCountry(), __);
  5. assertEquals(locBR.getDisplayCountry(locBR), __);
  6. Locale locCH = new Locale("it", "CH");
  7. assertEquals(locCH.getDisplayCountry(), __);
  8. assertEquals(locCH.getDisplayCountry(locCH), __);
  9. assertEquals(locCH.getDisplayCountry(new Locale("de", "CH")), __);
  10. }

相关文章