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

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

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

Locale.getISOCountries介绍

[英]Returns an array of strings containing all the two-letter ISO 3166 country codes that can be used as the country code when constructing a Locale.
[中]

代码示例

代码示例来源: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. 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. String[] isoCountryCodes = Locale.getISOCountries();
  2. for (String countryCode : isoCountryCodes) {
  3. Locale locale = new Locale("", countryCode);
  4. String countryName = locale.getDisplayCountry();
  5. }

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

  1. import java.util.*;
  2. import java.util.Locale;
  3. public class Donors {
  4. public static void main (String [] args) {
  5. for (final String code : Locale.getISOCountries()) {
  6. System.out.println (code);
  7. }
  8. }
  9. }

代码示例来源:origin: com.covisint.platform.legacy/legacy-support

  1. /** Loads the set of country codes for the first time. */
  2. private static synchronized void loadCountryCodes() {
  3. if (iso3166CountryCodes != null) {
  4. return;
  5. }
  6. iso3166CountryCodes = new HashSet<>(Arrays.asList(Locale.getISOCountries()));
  7. }

代码示例来源:origin: org.restcomm/restcomm-connect.provisioning.number.nexmo

  1. @Override
  2. public List<String> getAvailableCountries() {
  3. List<String> countries = new ArrayList<String>();
  4. String[] locales = Locale.getISOCountries();
  5. for (String countryCode : locales) {
  6. countries.add(countryCode);
  7. }
  8. return countries;
  9. }
  10. }

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

  1. public static Map<String, String> mapTimezonesToCountries() {
  2. Map<String, String> timezoneToCountry = new HashMap<>();
  3. String[] locales = Locale.getISOCountries();
  4. for (String countryCode : locales) {
  5. for (String id : com.ibm.icu.util.TimeZone.getAvailableIDs(countryCode))
  6. {
  7. // Add timezone to result map
  8. timezoneToCountry.put(id, countryCode);
  9. }
  10. }
  11. return timezoneToCountry;
  12. }

代码示例来源:origin: com.covisint.platform.user.core/user-core

  1. /** Loads the set of country codes for the first time. */
  2. private static synchronized void loadCountryCodes() {
  3. if (iso3166CountryCodes != null) {
  4. return;
  5. }
  6. iso3166CountryCodes = new HashSet<>(Arrays.asList(Locale.getISOCountries()));
  7. }

代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls

  1. public CountrySmartFieldModel() {
  2. String[] isoCountries = Locale.getISOCountries();
  3. List<Locale> locs = new ArrayList<>(isoCountries.length);
  4. for (String isoCountry : isoCountries) {
  5. locs.add(new Locale("", isoCountry));
  6. }
  7. m_locales = locs;
  8. }

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

  1. public final class IsoUtil {
  2. private static final Set<String> ISO_LANGUAGES = new HashSet<String>
  3. (Arrays.asList(Locale.getISOLanguages()));
  4. private static final Set<String> ISO_COUNTRIES = new HashSet<String>
  5. (Arrays.asList(Locale.getISOCountries()));
  6. private IsoUtil() {}
  7. public static boolean isValidISOLanguage(String s) {
  8. return ISO_LANGUAGES.contains(s);
  9. }
  10. public static boolean isValidISOCountry(String s) {
  11. return ISO_COUNTRIES.contains(s);
  12. }
  13. }

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

  1. Locale locale = Locale.GERMAN;
  2. for (String country : Locale.getISOCountries())
  3. {
  4. System.out.println(new Locale("", country).getDisplayCountry(locale));
  5. }

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

  1. String[] locales = Locale.getISOCountries();
  2. List<String> list = new ArrayList<>(500); // <-- List interface, and diamond
  3. // operator.
  4. Locale outLocale = new Locale("EN", "us"); // <-- English US
  5. for (String countryCode : locales) {
  6. Locale obj = new Locale("en-us", countryCode);
  7. list.add(obj.getDisplayCountry(outLocale));
  8. }
  9. Collections.sort(list);
  10. String[] country = list.toArray(new String[list.size()]);
  11. System.out.println(Arrays.toString(country));

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

  1. JComboBox box=new JComboBox(getAllCountries());
  2. public String[] getAllCountries() {
  3. String[] countries = new String[Locale.getISOCountries().length];
  4. String[] countryCodes = Locale.getISOCountries();
  5. for (int i = 0; i < countryCodes.length; i++) {
  6. Locale obj = new Locale("", countryCodes[i]);
  7. countries[i] = obj.getDisplayCountry();
  8. }
  9. return countries;
  10. }

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

  1. List<String> countriesList = new ArrayList<String>();
  2. String[] locales = Locale.getISOCountries();
  3. for (String countryCode : locales) {
  4. Locale obj = new Locale("", countryCode);
  5. countriesList.add(obj.getDisplayCountry(Locale.FRENCH));
  6. Collections.sort(countriesList);
  7. }
  8. for(String s:countriesList)
  9. {
  10. System.out.println(s);
  11. }

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

  1. String[] locales = Locale.getISOCountries();
  2. Locale locale;
  3. for (String countryCode : locales) {
  4. locale = new Locale("", countryCode);
  5. if(locale.getDisplayCountry().equals(cName){
  6. countryCode = locale.getCountry();
  7. break;
  8. }
  9. }

代码示例来源:origin: stripe/stripe-android

  1. @NonNull
  2. static Map<String, String> getCountryNameToCodeMap() {
  3. final Map<String, String> displayNameToCountryCode = new HashMap<>();
  4. for (String countryCode : Locale.getISOCountries()) {
  5. final Locale locale = new Locale("", countryCode);
  6. displayNameToCountryCode.put(locale.getDisplayCountry(), countryCode);
  7. }
  8. return displayNameToCountryCode;
  9. }

代码示例来源: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. private HashMap<String, String> countries = new HashMap<String, String>();
  2. String[] countryCodes = Locale.getISOCountries();
  3. for (String cc : countryCodes) {
  4. // country name , country code map
  5. countries.put(new Locale("", cc).getDisplayCountry(), cc.toUpperCase());
  6. }

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

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

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

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

相关文章