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")); }
String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { Locale obj = new Locale("", countryCode); System.out.println("Country Code = " + obj.getCountry() + ", Country Name = " + obj.getDisplayCountry()); }
String[] isoCountryCodes = Locale.getISOCountries(); for (String countryCode : isoCountryCodes) { Locale locale = new Locale("", countryCode); String countryName = locale.getDisplayCountry(); }
import java.util.*; import java.util.Locale; public class Donors { public static void main (String [] args) { for (final String code : Locale.getISOCountries()) { System.out.println (code); } } }
/** Loads the set of country codes for the first time. */ private static synchronized void loadCountryCodes() { if (iso3166CountryCodes != null) { return; } iso3166CountryCodes = new HashSet<>(Arrays.asList(Locale.getISOCountries())); }
@Override public List<String> getAvailableCountries() { List<String> countries = new ArrayList<String>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { countries.add(countryCode); } return countries; } }
public static Map<String, String> mapTimezonesToCountries() { Map<String, String> timezoneToCountry = new HashMap<>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { for (String id : com.ibm.icu.util.TimeZone.getAvailableIDs(countryCode)) { // Add timezone to result map timezoneToCountry.put(id, countryCode); } } return timezoneToCountry; }
/** Loads the set of country codes for the first time. */ private static synchronized void loadCountryCodes() { if (iso3166CountryCodes != null) { return; } iso3166CountryCodes = new HashSet<>(Arrays.asList(Locale.getISOCountries())); }
public CountrySmartFieldModel() { String[] isoCountries = Locale.getISOCountries(); List<Locale> locs = new ArrayList<>(isoCountries.length); for (String isoCountry : isoCountries) { locs.add(new Locale("", isoCountry)); } m_locales = locs; }
public final class IsoUtil { private static final Set<String> ISO_LANGUAGES = new HashSet<String> (Arrays.asList(Locale.getISOLanguages())); private static final Set<String> ISO_COUNTRIES = new HashSet<String> (Arrays.asList(Locale.getISOCountries())); private IsoUtil() {} public static boolean isValidISOLanguage(String s) { return ISO_LANGUAGES.contains(s); } public static boolean isValidISOCountry(String s) { return ISO_COUNTRIES.contains(s); } }
Locale locale = Locale.GERMAN; for (String country : Locale.getISOCountries()) { System.out.println(new Locale("", country).getDisplayCountry(locale)); }
String[] locales = Locale.getISOCountries(); List<String> list = new ArrayList<>(500); // <-- List interface, and diamond // operator. Locale outLocale = new Locale("EN", "us"); // <-- English US for (String countryCode : locales) { Locale obj = new Locale("en-us", countryCode); list.add(obj.getDisplayCountry(outLocale)); } Collections.sort(list); String[] country = list.toArray(new String[list.size()]); System.out.println(Arrays.toString(country));
JComboBox box=new JComboBox(getAllCountries()); public String[] getAllCountries() { String[] countries = new String[Locale.getISOCountries().length]; String[] countryCodes = Locale.getISOCountries(); for (int i = 0; i < countryCodes.length; i++) { Locale obj = new Locale("", countryCodes[i]); countries[i] = obj.getDisplayCountry(); } return countries; }
List<String> countriesList = new ArrayList<String>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { Locale obj = new Locale("", countryCode); countriesList.add(obj.getDisplayCountry(Locale.FRENCH)); Collections.sort(countriesList); } for(String s:countriesList) { System.out.println(s); }
String[] locales = Locale.getISOCountries(); Locale locale; for (String countryCode : locales) { locale = new Locale("", countryCode); if(locale.getDisplayCountry().equals(cName){ countryCode = locale.getCountry(); break; } }
@NonNull static Map<String, String> getCountryNameToCodeMap() { final Map<String, String> displayNameToCountryCode = new HashMap<>(); for (String countryCode : Locale.getISOCountries()) { final Locale locale = new Locale("", countryCode); displayNameToCountryCode.put(locale.getDisplayCountry(), countryCode); } return displayNameToCountryCode; }
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")); }
private HashMap<String, String> countries = new HashMap<String, String>(); String[] countryCodes = Locale.getISOCountries(); for (String cc : countryCodes) { // country name , country code map countries.put(new Locale("", cc).getDisplayCountry(), cc.toUpperCase()); }
ArrayList<String> list=new ArrayList<String>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { Locale obj = new Locale("", countryCode); System.out.println("Country Name = " + obj.getDisplayCountry()); list.add(obj.getDisplayCountry()); }
ArrayList<String> list=new ArrayList<String>(); String[] locales = Locale.getISOCountries(); for (String countryCode : locales) { Locale obj = new Locale("", countryCode); System.out.println("Country Name = " + obj.getDisplayCountry()); list.add(obj.getDisplayCountry()); }