本文整理了Java中java.util.Locale.getISOCountries()
方法的一些代码示例,展示了Locale.getISOCountries()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Locale.getISOCountries()
方法的具体详情如下:
包路径:java.util.Locale
类名称: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
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
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
String[] isoCountryCodes = Locale.getISOCountries();
for (String countryCode : isoCountryCodes) {
Locale locale = new Locale("", countryCode);
String countryName = locale.getDisplayCountry();
}
代码示例来源:origin: stackoverflow.com
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);
}
}
}
代码示例来源:origin: com.covisint.platform.legacy/legacy-support
/** 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()));
}
代码示例来源:origin: org.restcomm/restcomm-connect.provisioning.number.nexmo
@Override
public List<String> getAvailableCountries() {
List<String> countries = new ArrayList<String>();
String[] locales = Locale.getISOCountries();
for (String countryCode : locales) {
countries.add(countryCode);
}
return countries;
}
}
代码示例来源:origin: stackoverflow.com
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;
}
代码示例来源:origin: com.covisint.platform.user.core/user-core
/** 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()));
}
代码示例来源:origin: org.eclipse.scout.sdk.s2e/org.eclipse.scout.sdk.s2e.nls
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;
}
代码示例来源:origin: stackoverflow.com
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);
}
}
代码示例来源:origin: stackoverflow.com
Locale locale = Locale.GERMAN;
for (String country : Locale.getISOCountries())
{
System.out.println(new Locale("", country).getDisplayCountry(locale));
}
代码示例来源:origin: stackoverflow.com
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));
代码示例来源:origin: stackoverflow.com
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;
}
代码示例来源:origin: stackoverflow.com
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);
}
代码示例来源:origin: stackoverflow.com
String[] locales = Locale.getISOCountries();
Locale locale;
for (String countryCode : locales) {
locale = new Locale("", countryCode);
if(locale.getDisplayCountry().equals(cName){
countryCode = locale.getCountry();
break;
}
}
代码示例来源:origin: stripe/stripe-android
@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;
}
代码示例来源: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
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());
}
代码示例来源:origin: stackoverflow.com
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());
}
代码示例来源:origin: stackoverflow.com
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());
}
内容来源于网络,如有侵权,请联系作者删除!