java.util.Locale#getDisplayCountry ( )源码实例Demo

下面列出了java.util.Locale#getDisplayCountry ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: EasyVPN-Free   文件: CountriesNames.java
public static Map<String, String> getCountries() {
    Map<String, String> countries = new HashMap<String, String>();

    String[] isoCountries = Locale.getISOCountries();
    for (String country : isoCountries) {
        Locale locale = new Locale("", country);
        String iso = locale.getISO3Country();
        String code = locale.getCountry();
        String name = locale.getDisplayCountry();

        if (!"".equals(iso) && !"".equals(code)
                && !"".equals(name)) {
            countries.put(code, name);
        }
    }

    return countries;
}
 
源代码2 项目: Spark   文件: SpellcheckChatRoomDecorator.java
private void languagestoLocales()
{
    String spellLanguage = SpellcheckManager.getInstance().getSpellcheckerPreference().getPreferences().getSpellLanguage();
    _languages = new HashMap<String, String>();
    Locale[] locales = Locale.getAvailableLocales();
    ArrayList<String> languages = SpellcheckManager.getInstance().getSupportedLanguages();
    for (int i = 0; i < languages.size(); i++) {
        for (final Locale locale : locales) {
            if (locale.toString().equals(languages.get(i))) {
                String label = locale.getDisplayLanguage(Locale
                        .getDefault());
                if (locale.getDisplayCountry(locale) != null
                        && locale.getDisplayCountry(locale).trim().length() > 0) {
                    label = label + "-"
                            + locale.getDisplayCountry(locale).trim();
                }
                _languages.put(label, languages.get(i));
                _languageSelection.addItem(label);
                if (languages.get(i).equals(spellLanguage))
                {
                    _languageSelection.setSelectedItem(label);
                }
                
            }
        }
    }
}
 
源代码3 项目: openjdk-jdk9   文件: CurrencyTest.java
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
源代码4 项目: bisq   文件: CountryUtil.java
private static void populateCountryListByCodes(List<Country> list, String[] codes) {
    for (String code : codes) {
        Locale locale = new Locale(LanguageUtil.getDefaultLanguage(), code, "");
        final String countryCode = locale.getCountry();
        String regionCode = getRegionCode(countryCode);
        final Region region = new Region(regionCode, getRegionName(regionCode));
        Country country = new Country(countryCode, locale.getDisplayCountry(), region);
        if (countryCode.equals("XK"))
            country = new Country(countryCode, getNameByCode(countryCode), region);
        list.add(country);
    }
}
 
源代码5 项目: nextreports-designer   文件: LocaleUtil.java
public static List<Country> getCountries() {
	List<Country> countries = new ArrayList<Country>();
	Locale[] locales = Locale.getAvailableLocales();
	for (Locale locale : locales) {
		String iso = "NA";
		try {
			iso = locale.getISO3Country();
		} catch (MissingResourceException ex) {				
		}
		String code = locale.getCountry();
		String name = locale.getDisplayCountry();
		String language = locale.getLanguage();

		if (!"".equals(iso) && !"".equals(code) && !"".equals(name)) {				
			Country c = new Country(iso, code, name, language);
			if (!countries.contains(c)) {
				countries.add(c);
			}	
		}
	}

	Collections.sort(countries, new Comparator<Country>() {
		@Override
		public int compare(Country c1, Country c2) {
			 return Collator.getInstance().compare(c1.getName(), c2.getName());
		}
		
	});	
	return countries;
}
 
源代码6 项目: jdk8u-dev-jdk   文件: CurrencyTest.java
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
源代码7 项目: jdk8u60   文件: CurrencyTest.java
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
源代码8 项目: smartcoins-wallet   文件: Helper.java
public static String getSpinnertextCountry(String countryCode) {

        Locale locale = new Locale("", countryCode);
        try {
            Currency currency = Currency.getInstance(locale);
            return locale.getDisplayCountry() + " (" + currency.getCurrencyCode() + ")";
        } catch (Exception e) {

        }
        return "";
    }
 
源代码9 项目: openjdk-jdk8u   文件: CurrencyTest.java
static void checkCountryCurrency(String countryCode, String expected) {
    Locale locale = new Locale("", countryCode);
    Currency currency = Currency.getInstance(locale);
    String code = (currency != null) ? currency.getCurrencyCode() : null;
    if (!(expected == null ? code == null : expected.equals(code))) {
        throw new RuntimeException("Wrong currency for " +
                locale.getDisplayCountry() +
                ": expected " + expected + ", got " + code);
    }
}
 
源代码10 项目: dragonwell8_jdk   文件: LocaleTest.java
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
        errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
    else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
        errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String  testLang;
        String  testCtry;
        String  testVar;
        String  testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        }
        else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String  expectedLang;
        String  expectedCtry;
        String  expectedVar;
        String  expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench)
            expectedLang = dataTable[DLANG_EN][i];
        if (expectedLang.equals(""))
            expectedLang = dataTable[DLANG_ROOT][i];

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench)
            expectedCtry = dataTable[DCTRY_EN][i];
        if (expectedCtry.equals(""))
            expectedCtry = dataTable[DCTRY_ROOT][i];

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench)
            expectedVar = dataTable[DVAR_EN][i];
        if (expectedVar.equals(""))
            expectedVar = dataTable[DVAR_ROOT][i];

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench)
            expectedName = dataTable[DNAME_EN][i];
        if (expectedName.equals(""))
            expectedName = dataTable[DNAME_ROOT][i];

        if (!testLang.equals(expectedLang))
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        if (!testCtry.equals(expectedCtry))
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        if (!testVar.equals(expectedVar))
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        if (!testName.equals(expectedName))
            errln("Display name mismatch: " + testName + " versus " + expectedName);
    }
}
 
源代码11 项目: TencentKona-8   文件: HongKong.java
private static void checkCountry(Locale country, String expected) {
    String actual = country.getDisplayCountry();
    if (!expected.equals(actual)) {
        throw new RuntimeException();
    }
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: LocaleTest.java
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
        errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
    else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
        errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String  testLang;
        String  testCtry;
        String  testVar;
        String  testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        }
        else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String  expectedLang;
        String  expectedCtry;
        String  expectedVar;
        String  expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench)
            expectedLang = dataTable[DLANG_EN][i];
        if (expectedLang.equals(""))
            expectedLang = dataTable[DLANG_ROOT][i];

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench)
            expectedCtry = dataTable[DCTRY_EN][i];
        if (expectedCtry.equals(""))
            expectedCtry = dataTable[DCTRY_ROOT][i];

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench)
            expectedVar = dataTable[DVAR_EN][i];
        if (expectedVar.equals(""))
            expectedVar = dataTable[DVAR_ROOT][i];

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench)
            expectedName = dataTable[DNAME_EN][i];
        if (expectedName.equals(""))
            expectedName = dataTable[DNAME_ROOT][i];

        if (!testLang.equals(expectedLang))
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        if (!testCtry.equals(expectedCtry))
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        if (!testVar.equals(expectedVar))
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        if (!testName.equals(expectedName))
            errln("Display name mismatch: " + testName + " versus " + expectedName);
    }
}
 
源代码13 项目: TencentKona-8   文件: Bug4640234.java
/**
* Compares the english timezone name and timezone name in specified locale
* @param timeZoneName - name of the timezone to compare
* @param locale - locale to test against english
* @return empty string when passed, descriptive error message in other cases
*/
private static String testTZ(String timeZoneName, Locale locale) {
    StringBuffer timeZoneResult = new StringBuffer("");
    TimeZone tz = TimeZone.getTimeZone(timeZoneName);
    sdfEn.setTimeZone(tz);
    sdfEnShort.setTimeZone(tz);
    sdfLoc.setTimeZone(tz);
    sdfLocShort.setTimeZone(tz);

    String en, enShort, loc, locShort;
    en = sdfEn.format(date);
    enShort = sdfEnShort.format(date);
    loc = sdfLoc.format(date);
    locShort = sdfLocShort.format(date);

    String displayLanguage = locale.getDisplayLanguage();
    String displayCountry = locale.getDisplayCountry();

    if (loc.equals(en)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" long name \"" + en);
        timeZoneResult.append("\" not localized!\n");
    }

    if (!locShort.equals(enShort)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" short name \"" + enShort);
        timeZoneResult.append("\" is localized \"");
        timeZoneResult.append(locShort);
        timeZoneResult.append("\"!\n");
    }
    return timeZoneResult.toString();
}
 
源代码14 项目: jdk8u-jdk   文件: Bug4640234.java
/**
* Compares the english timezone name and timezone name in specified locale
* @param timeZoneName - name of the timezone to compare
* @param locale - locale to test against english
* @return empty string when passed, descriptive error message in other cases
*/
private static String testTZ(String timeZoneName, Locale locale) {
    StringBuffer timeZoneResult = new StringBuffer("");
    TimeZone tz = TimeZone.getTimeZone(timeZoneName);
    sdfEn.setTimeZone(tz);
    sdfEnShort.setTimeZone(tz);
    sdfLoc.setTimeZone(tz);
    sdfLocShort.setTimeZone(tz);

    String en, enShort, loc, locShort;
    en = sdfEn.format(date);
    enShort = sdfEnShort.format(date);
    loc = sdfLoc.format(date);
    locShort = sdfLocShort.format(date);

    String displayLanguage = locale.getDisplayLanguage();
    String displayCountry = locale.getDisplayCountry();

    if (loc.equals(en)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" long name \"" + en);
        timeZoneResult.append("\" not localized!\n");
    }

    if (!locShort.equals(enShort)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" short name \"" + enShort);
        timeZoneResult.append("\" is localized \"");
        timeZoneResult.append(locShort);
        timeZoneResult.append("\"!\n");
    }
    return timeZoneResult.toString();
}
 
源代码15 项目: jdk8u-jdk   文件: Bug4640234.java
/**
* Compares the english timezone name and timezone name in specified locale
* @param timeZoneName - name of the timezone to compare
* @param locale - locale to test against english
* @return empty string when passed, descriptive error message in other cases
*/
private static String testTZ(String timeZoneName, Locale locale) {
    StringBuffer timeZoneResult = new StringBuffer("");
    TimeZone tz = TimeZone.getTimeZone(timeZoneName);
    sdfEn.setTimeZone(tz);
    sdfEnShort.setTimeZone(tz);
    sdfLoc.setTimeZone(tz);
    sdfLocShort.setTimeZone(tz);

    String en, enShort, loc, locShort;
    en = sdfEn.format(date);
    enShort = sdfEnShort.format(date);
    loc = sdfLoc.format(date);
    locShort = sdfLocShort.format(date);

    String displayLanguage = locale.getDisplayLanguage();
    String displayCountry = locale.getDisplayCountry();

    if (loc.equals(en)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" long name \"" + en);
        timeZoneResult.append("\" not localized!\n");
    }

    if (!locShort.equals(enShort)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" short name \"" + enShort);
        timeZoneResult.append("\" is localized \"");
        timeZoneResult.append(locShort);
        timeZoneResult.append("\"!\n");
    }
    return timeZoneResult.toString();
}
 
源代码16 项目: hottub   文件: LocaleTest.java
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
        errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
    else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
        errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String  testLang;
        String  testCtry;
        String  testVar;
        String  testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        }
        else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String  expectedLang;
        String  expectedCtry;
        String  expectedVar;
        String  expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench)
            expectedLang = dataTable[DLANG_EN][i];
        if (expectedLang.equals(""))
            expectedLang = dataTable[DLANG_ROOT][i];

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench)
            expectedCtry = dataTable[DCTRY_EN][i];
        if (expectedCtry.equals(""))
            expectedCtry = dataTable[DCTRY_ROOT][i];

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench)
            expectedVar = dataTable[DVAR_EN][i];
        if (expectedVar.equals(""))
            expectedVar = dataTable[DVAR_ROOT][i];

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench)
            expectedName = dataTable[DNAME_EN][i];
        if (expectedName.equals(""))
            expectedName = dataTable[DNAME_ROOT][i];

        if (!testLang.equals(expectedLang))
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        if (!testCtry.equals(expectedCtry))
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        if (!testVar.equals(expectedVar))
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        if (!testName.equals(expectedName))
            errln("Display name mismatch: " + testName + " versus " + expectedName);
    }
}
 
源代码17 项目: openjdk-8   文件: LocaleTest.java
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
        errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
    else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
        errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String  testLang;
        String  testCtry;
        String  testVar;
        String  testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        }
        else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String  expectedLang;
        String  expectedCtry;
        String  expectedVar;
        String  expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench)
            expectedLang = dataTable[DLANG_EN][i];
        if (expectedLang.equals(""))
            expectedLang = dataTable[DLANG_ROOT][i];

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench)
            expectedCtry = dataTable[DCTRY_EN][i];
        if (expectedCtry.equals(""))
            expectedCtry = dataTable[DCTRY_ROOT][i];

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench)
            expectedVar = dataTable[DVAR_EN][i];
        if (expectedVar.equals(""))
            expectedVar = dataTable[DVAR_ROOT][i];

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench)
            expectedName = dataTable[DNAME_EN][i];
        if (expectedName.equals(""))
            expectedName = dataTable[DNAME_ROOT][i];

        if (!testLang.equals(expectedLang))
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        if (!testCtry.equals(expectedCtry))
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        if (!testVar.equals(expectedVar))
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        if (!testName.equals(expectedName))
            errln("Display name mismatch: " + testName + " versus " + expectedName);
    }
}
 
源代码18 项目: openjdk-jdk8u   文件: LocaleTest.java
private void doTestDisplayNames(Locale inLocale, int compareIndex, boolean defaultIsFrench) {
    if (defaultIsFrench && !Locale.getDefault().getLanguage().equals("fr"))
        errln("Default locale should be French, but it's really " + Locale.getDefault().getLanguage());
    else if (!defaultIsFrench && !Locale.getDefault().getLanguage().equals("en"))
        errln("Default locale should be English, but it's really " + Locale.getDefault().getLanguage());

    for (int i = 0; i <= MAX_LOCALES; i++) {
        Locale testLocale = new Locale(dataTable[LANG][i], dataTable[CTRY][i], dataTable[VAR][i]);
        logln("  Testing " + testLocale + "...");

        String  testLang;
        String  testCtry;
        String  testVar;
        String  testName;

        if (inLocale == null) {
            testLang = testLocale.getDisplayLanguage();
            testCtry = testLocale.getDisplayCountry();
            testVar = testLocale.getDisplayVariant();
            testName = testLocale.getDisplayName();
        }
        else {
            testLang = testLocale.getDisplayLanguage(inLocale);
            testCtry = testLocale.getDisplayCountry(inLocale);
            testVar = testLocale.getDisplayVariant(inLocale);
            testName = testLocale.getDisplayName(inLocale);
        }

        String  expectedLang;
        String  expectedCtry;
        String  expectedVar;
        String  expectedName;

        expectedLang = dataTable[compareIndex][i];
        if (expectedLang.equals("") && defaultIsFrench)
            expectedLang = dataTable[DLANG_EN][i];
        if (expectedLang.equals(""))
            expectedLang = dataTable[DLANG_ROOT][i];

        expectedCtry = dataTable[compareIndex + 1][i];
        if (expectedCtry.equals("") && defaultIsFrench)
            expectedCtry = dataTable[DCTRY_EN][i];
        if (expectedCtry.equals(""))
            expectedCtry = dataTable[DCTRY_ROOT][i];

        expectedVar = dataTable[compareIndex + 2][i];
        if (expectedVar.equals("") && defaultIsFrench)
            expectedVar = dataTable[DVAR_EN][i];
        if (expectedVar.equals(""))
            expectedVar = dataTable[DVAR_ROOT][i];

        expectedName = dataTable[compareIndex + 3][i];
        if (expectedName.equals("") && defaultIsFrench)
            expectedName = dataTable[DNAME_EN][i];
        if (expectedName.equals(""))
            expectedName = dataTable[DNAME_ROOT][i];

        if (!testLang.equals(expectedLang))
            errln("Display language mismatch: " + testLang + " versus " + expectedLang);
        if (!testCtry.equals(expectedCtry))
            errln("Display country mismatch: " + testCtry + " versus " + expectedCtry);
        if (!testVar.equals(expectedVar))
            errln("Display variant mismatch: " + testVar + " versus " + expectedVar);
        if (!testName.equals(expectedName))
            errln("Display name mismatch: " + testName + " versus " + expectedName);
    }
}
 
源代码19 项目: openjdk-jdk8u   文件: Bug4640234.java
/**
* Compares the english timezone name and timezone name in specified locale
* @param timeZoneName - name of the timezone to compare
* @param locale - locale to test against english
* @return empty string when passed, descriptive error message in other cases
*/
private static String testTZ(String timeZoneName, Locale locale) {
    StringBuffer timeZoneResult = new StringBuffer("");
    TimeZone tz = TimeZone.getTimeZone(timeZoneName);
    sdfEn.setTimeZone(tz);
    sdfEnShort.setTimeZone(tz);
    sdfLoc.setTimeZone(tz);
    sdfLocShort.setTimeZone(tz);

    String en, enShort, loc, locShort;
    en = sdfEn.format(date);
    enShort = sdfEnShort.format(date);
    loc = sdfLoc.format(date);
    locShort = sdfLocShort.format(date);

    String displayLanguage = locale.getDisplayLanguage();
    String displayCountry = locale.getDisplayCountry();

    if (loc.equals(en)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" long name \"" + en);
        timeZoneResult.append("\" not localized!\n");
    }

    if (!locShort.equals(enShort)) {
        timeZoneResult.append("[");
        timeZoneResult.append(displayLanguage);
        if (!"".equals(displayCountry)) {
            timeZoneResult.append(" ");
            timeZoneResult.append(displayCountry);
        }
        timeZoneResult.append("] timezone \"");
        timeZoneResult.append(timeZoneName);
        timeZoneResult.append("\" short name \"" + enShort);
        timeZoneResult.append("\" is localized \"");
        timeZoneResult.append(locShort);
        timeZoneResult.append("\"!\n");
    }
    return timeZoneResult.toString();
}
 
源代码20 项目: V2EX   文件: GeneralPreferenceFragment.java
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getPreferenceManager().setSharedPreferencesName(
            Config.getConfig(ConfigRefEnum.CONFIG_PREFERENCE_SETTING_FILE));
    addPreferencesFromResource(R.xml.pref_general);

    ListPreference themePreference = (ListPreference) findPreference(
            getString(R.string.key_theme));
    themePreference.setSummary(Config.getConfig(ConfigRefEnum.CONFIG_THEME));

    ListPreference dateFormatPreference = (ListPreference)findPreference(
            getString(R.string.key_date_format));
    String[] dateEntries = new String[dateFormatPreference.getEntryValues().length];
    int i = 0;
    for (CharSequence s:dateFormatPreference.getEntryValues()){
        String date = TimeUtil.getDateNow(String.valueOf(s));
        dateEntries[i++] = date;
    }
    dateFormatPreference.setEntries(dateEntries);
    dateFormatPreference.setSummary(TimeUtil.getDateNow(Config.getConfig(
            ConfigRefEnum.CONFIG_DATE_FORMAT)));

    ListPreference localePreference = (ListPreference) findPreference(getString(R.string.key_local));
    String[] localesEntryValue = new String[Config.LOCAL_LIST.size()];
    String[] localesEntries= new String[Config.LOCAL_LIST.size()];
    int index = 0;
    for (Locale locale:Config.LOCAL_LIST){
        localesEntryValue[index] = locale.toString();
        localesEntries[index++] = locale.getDisplayCountry();
    }
    localePreference.setDefaultValue(localesEntryValue[0]);
    localePreference.setEntryValues(localesEntryValue);
    localePreference.setEntries(localesEntries);

    Preference clearCachePreference = findPreference(getString(R.string.clear_cache));
    clearCachePreference.setOnPreferenceClickListener(this::clearCache);
    clearCachePreference.setSummary("缓存大小 12 MB");
    findPreference(getString(R.string.key_home_tabs)).setOnPreferenceClickListener(preference -> {
        CustomTabActivity.start(getActivity());
        return false;
    });
}