Java Code Examples for java.util.Locale#CHINESE

The following examples show how to use java.util.Locale#CHINESE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseActivity.java    From talk-android with MIT License 6 votes vote down vote up
protected void switchLanguage(String language) {
    if (!"zh".equals(language) && !"en".equals(language)) {
        return;
    } else {
        MainApp.PREF_UTIL.putString(Constant.LANGUAGE_PREF, language);
    }
    Resources resources = getResources();
    Configuration config = resources.getConfiguration();
    DisplayMetrics dm = resources.getDisplayMetrics();
    if (language.equals("en")) {
        config.locale = Locale.ENGLISH;
    } else {
        config.locale = Locale.CHINESE;
    }
    resources.updateConfiguration(config, dm);
}
 
Example 2
Source File: ResponseStatusExceptionResolverTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void statusCodeAndReasonMessage() {
	Locale locale = Locale.CHINESE;
	LocaleContextHolder.setLocale(locale);
	try {
		StaticMessageSource messageSource = new StaticMessageSource();
		messageSource.addMessage("gone.reason", locale, "Gone reason message");
		exceptionResolver.setMessageSource(messageSource);

		StatusCodeAndReasonMessageException ex = new StatusCodeAndReasonMessageException();
		exceptionResolver.resolveException(request, response, null, ex);
		assertEquals("Invalid status reason", "Gone reason message", response.getErrorMessage());
	}
	finally {
		LocaleContextHolder.resetLocaleContext();
	}
}
 
Example 3
Source File: ResourceHolder.java    From database-transform-tool with Apache License 2.0 6 votes vote down vote up
/**
 * <pre>
 * 描述:获取本地语言
 * 作者:ZhangYi
 * 时间:2015年1月30日 下午1:24:06
 * 参数:(参数列表)
 * @param language
 * @return
 * </pre>
 */
public static Locale getLocale(String language) {
	Locale locale = Locale.CHINESE;
	if (!StringUtil.isEmpty(language)) {
		language = language.toLowerCase();
		if (language.indexOf("en") != -1) {
			locale = Locale.ENGLISH;
		}
		if (language.indexOf("zh_hk") != -1) {
			locale = Locale.TRADITIONAL_CHINESE;
		}
		if (language.indexOf("zh_cn") != -1) {
			locale = Locale.SIMPLIFIED_CHINESE;
		}
	}
	return locale;
}
 
Example 4
Source File: LocalManageUtil.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
/**
 * 获取选择的语言设置
 *
 * @return
 */
public static Locale getSetLanguageLocale() {
    int language = Arad.preferences.getInteger(Constants.P_SETTING_LANGUAGE, -1);

    switch (language) {
        case 0:
            return Locale.CHINESE;
        case 1:
            return Locale.TAIWAN;
        case 2:
            return Locale.ENGLISH;
        case 3:
            return Locale.JAPANESE;
        case 4:
            return Locale.KOREAN;
        default:
            return getSystemLocale();
    }
}
 
Example 5
Source File: LocaleTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @bug 4105828
 * Currency symbol in zh is wrong.  We will test this at the NumberFormat
 * end to test the whole pipe.
 */
public void Test4105828() {
    Locale[] LOC = { Locale.CHINESE, new Locale("zh", "CN", ""),
                     new Locale("zh", "TW", ""), new Locale("zh", "HK", "") };
    for (int i=0; i<LOC.length; ++i) {
        NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
        String result = fmt.format(1);
        if (!result.equals("100%")) {
            errln("Percent for " + LOC[i] + " should be 100%, got " + result);
        }
    }
}
 
Example 6
Source File: LocaleTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @bug 4105828
 * Currency symbol in zh is wrong.  We will test this at the NumberFormat
 * end to test the whole pipe.
 */
public void Test4105828() {
    Locale[] LOC = {Locale.CHINESE, new Locale("zh", "CN", ""),
        new Locale("zh", "TW", ""), new Locale("zh", "HK", "")};
    for (int i = 0; i < LOC.length; ++i) {
        NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
        String result = fmt.format(1);
        if (!result.equals("100%")) {
            errln("Percent for " + LOC[i] + " should be 100%, got " + result);
        }
    }
}
 
Example 7
Source File: LocaleTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @bug 4105828
 * Currency symbol in zh is wrong.  We will test this at the NumberFormat
 * end to test the whole pipe.
 */
public void Test4105828() {
    Locale[] LOC = { Locale.CHINESE, new Locale("zh", "CN", ""),
                     new Locale("zh", "TW", ""), new Locale("zh", "HK", "") };
    for (int i=0; i<LOC.length; ++i) {
        NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
        String result = fmt.format(1);
        if (!result.equals("100%")) {
            errln("Percent for " + LOC[i] + " should be 100%, got " + result);
        }
    }
}
 
Example 8
Source File: LocaleTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @bug 4105828
 * Currency symbol in zh is wrong.  We will test this at the NumberFormat
 * end to test the whole pipe.
 */
public void Test4105828() {
    Locale[] LOC = { Locale.CHINESE, new Locale("zh", "CN", ""),
                     new Locale("zh", "TW", ""), new Locale("zh", "HK", "") };
    for (int i=0; i<LOC.length; ++i) {
        NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
        String result = fmt.format(1);
        if (!result.equals("100%")) {
            errln("Percent for " + LOC[i] + " should be 100%, got " + result);
        }
    }
}
 
Example 9
Source File: LocaleTransform.java    From PictureSelector with Apache License 2.0 5 votes vote down vote up
public static Locale getLanguage(int language) {
    switch (language) {
        case LanguageConfig.ENGLISH:
            // 英语-美国
            return Locale.ENGLISH;
        case LanguageConfig.TRADITIONAL_CHINESE:
            // 繁体中文
            return Locale.TRADITIONAL_CHINESE;
        case LanguageConfig.KOREA:
            // 韩语
            return Locale.KOREA;
        case LanguageConfig.GERMANY:
            // 德语
            return Locale.GERMANY;
        case LanguageConfig.FRANCE:
            // 法语
            return Locale.FRANCE;
        case LanguageConfig.JAPAN:
            // 日语
            return Locale.JAPAN;
        case LanguageConfig.VIETNAM:
            // 越南语
            return new Locale("vi");
        default:
            // 简体中文
            return Locale.CHINESE;
    }
}
 
Example 10
Source File: StringUtils.java    From scallop with MIT License 5 votes vote down vote up
public static CharSequence getRelativeTime(String dateStr) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'S'Z'",
            Locale.CHINESE);
    try {
        Date date = dateFormat.parse(dateStr);
        long now = System.currentTimeMillis();
        return DateUtils.getRelativeTimeSpanString(date.getTime(), now, DateUtils.SECOND_IN_MILLIS);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return "N/A";
}
 
Example 11
Source File: LockAudioActivity.java    From YCAudioPlayer with Apache License 2.0 5 votes vote down vote up
private void initLockData() {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm-MM月dd日 E", Locale.CHINESE);
    String[] date = simpleDateFormat.format(new Date()).split("-");
    tvTime.setText(date[0]);
    tvDate.setText(date[1]);
    tvAuthor.setText("作者:杨充");
    tvName.setText("潇湘剑雨");
    ivImage.setImageResource(R.drawable.ic_person_author);
}
 
Example 12
Source File: LocaleTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @bug 4105828
 * Currency symbol in zh is wrong.  We will test this at the NumberFormat
 * end to test the whole pipe.
 */
public void Test4105828() {
    Locale[] LOC = { Locale.CHINESE, new Locale("zh", "CN", ""),
                     new Locale("zh", "TW", ""), new Locale("zh", "HK", "") };
    for (int i=0; i<LOC.length; ++i) {
        NumberFormat fmt = NumberFormat.getPercentInstance(LOC[i]);
        String result = fmt.format(1);
        if (!result.equals("100%")) {
            errln("Percent for " + LOC[i] + " should be 100%, got " + result);
        }
    }
}
 
Example 13
Source File: TestDateTimeFormatterBuilder.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name="localePatterns")
Object[][] localizedDateTimePatterns() {
    return new Object[][] {
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy h:mm:ss a"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "M/d/yy h:mm a"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.US, "M/d/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "h:mm a"},

        // French Locale and ISO Chronology
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy HH' h 'mm z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy HH:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy HH:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy HH:mm"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "HH' h 'mm z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm"},

        // Japanese Locale and JapaneseChronology
        {FormatStyle.FULL, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5' H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm"},
        {FormatStyle.FULL, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5'"},
        {FormatStyle.LONG, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.MEDIUM, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.SHORT, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {null, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss z"},
        {null, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm"},

        // Chinese Local and Chronology
        {FormatStyle.FULL, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5 ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d ah:mm"},
        {FormatStyle.FULL, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE"},
        {FormatStyle.LONG, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5"},
        {FormatStyle.MEDIUM, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {FormatStyle.SHORT, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {null, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {null, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "ah:mm"},
    };
}
 
Example 14
Source File: TestDateTimeFormatterBuilder.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name="localePatterns")
Object[][] localizedDateTimePatterns() {
    return new Object[][] {
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy h:mm:ss a"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "M/d/yy h:mm a"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.US, "M/d/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "h:mm a"},

        // French Locale and ISO Chronology
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy HH' h 'mm z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy HH:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy HH:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy HH:mm"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "HH' h 'mm z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm"},

        // Japanese Locale and JapaneseChronology
        {FormatStyle.FULL, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5' H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm"},
        {FormatStyle.FULL, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5'"},
        {FormatStyle.LONG, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.MEDIUM, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.SHORT, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {null, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss z"},
        {null, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm"},

        // Chinese Local and Chronology
        {FormatStyle.FULL, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5 ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d ah:mm"},
        {FormatStyle.FULL, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE"},
        {FormatStyle.LONG, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5"},
        {FormatStyle.MEDIUM, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {FormatStyle.SHORT, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {null, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {null, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "ah:mm"},
    };
}
 
Example 15
Source File: TestDateTimeFormatterBuilder.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name="localePatterns")
Object[][] localizedDateTimePatterns() {
    return new Object[][] {
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy h:mm:ss a"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "M/d/yy h:mm a"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.US, "M/d/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "h:mm a"},

        // French Locale and ISO Chronology
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy HH' h 'mm z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy HH:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy HH:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy HH:mm"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "HH' h 'mm z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm"},

        // Japanese Locale and JapaneseChronology
        {FormatStyle.FULL, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5' H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm"},
        {FormatStyle.FULL, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5'"},
        {FormatStyle.LONG, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.MEDIUM, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.SHORT, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {null, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss z"},
        {null, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm"},

        // Chinese Local and Chronology
        {FormatStyle.FULL, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5 ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d ah:mm"},
        {FormatStyle.FULL, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE"},
        {FormatStyle.LONG, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5"},
        {FormatStyle.MEDIUM, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {FormatStyle.SHORT, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {null, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {null, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "ah:mm"},
    };
}
 
Example 16
Source File: MessageCatalog.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private Locale getLocale(String localeName) {
    String language, country;
    int index;

    index = localeName.indexOf('_');
    if (index == -1) {
        //
        // Special case the builtin JDK languages
        //
        if (localeName.equals("de"))
            return Locale.GERMAN;
        if (localeName.equals("en"))
            return Locale.ENGLISH;
        if (localeName.equals("fr"))
            return Locale.FRENCH;
        if (localeName.equals("it"))
            return Locale.ITALIAN;
        if (localeName.equals("ja"))
            return Locale.JAPANESE;
        if (localeName.equals("ko"))
            return Locale.KOREAN;
        if (localeName.equals("zh"))
            return Locale.CHINESE;

        language = localeName;
        country = "";
    } else {
        if (localeName.equals("zh_CN"))
            return Locale.SIMPLIFIED_CHINESE;
        if (localeName.equals("zh_TW"))
            return Locale.TRADITIONAL_CHINESE;

        //
        // JDK also has constants for countries:  en_GB, en_US, en_CA,
        // fr_FR, fr_CA, de_DE, ja_JP, ko_KR.  We don't use those.
        //
        language = localeName.substring(0, index);
        country = localeName.substring(index + 1);
    }

    return new Locale(language, country);
}
 
Example 17
Source File: TestDateTimeFormatterBuilder.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@DataProvider(name="localePatterns")
Object[][] localizedDateTimePatterns() {
    return new Object[][] {
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy h:mm:ss a z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy h:mm:ss a"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "M/d/yy h:mm a"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.US, "EEEE, MMMM d, yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.US, "MMMM d, yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.US, "MMM d, yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.US, "M/d/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.US, "h:mm:ss a"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.US, "h:mm a"},

        // French Locale and ISO Chronology
        {FormatStyle.FULL, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy HH' h 'mm z"},
        {FormatStyle.LONG, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy HH:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy HH:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy HH:mm"},
        {FormatStyle.FULL, null, IsoChronology.INSTANCE, Locale.FRENCH, "EEEE d MMMM yyyy"},
        {FormatStyle.LONG, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMMM yyyy"},
        {FormatStyle.MEDIUM, null, IsoChronology.INSTANCE, Locale.FRENCH, "d MMM yyyy"},
        {FormatStyle.SHORT, null, IsoChronology.INSTANCE, Locale.FRENCH, "dd/MM/yy"},
        {null, FormatStyle.FULL, IsoChronology.INSTANCE, Locale.FRENCH, "HH' h 'mm z"},
        {null, FormatStyle.LONG, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss z"},
        {null, FormatStyle.MEDIUM, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm:ss"},
        {null, FormatStyle.SHORT, IsoChronology.INSTANCE, Locale.FRENCH, "HH:mm"},

        // Japanese Locale and JapaneseChronology
        {FormatStyle.FULL, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5' H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss z"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd H:mm"},
        {FormatStyle.FULL, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "Gy'\u5e74'M'\u6708'd'\u65e5'"},
        {FormatStyle.LONG, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.MEDIUM, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {FormatStyle.SHORT, null, JapaneseChronology.INSTANCE, Locale.JAPANESE, "GGGGGy.MM.dd"},
        {null, FormatStyle.FULL, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H'\u6642'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss z"},
        {null, FormatStyle.MEDIUM, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, JapaneseChronology.INSTANCE, Locale.JAPANESE, "H:mm"},

        // Chinese Local and Chronology
        {FormatStyle.FULL, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {FormatStyle.LONG, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5 ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {FormatStyle.MEDIUM, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d H:mm:ss"},
        {FormatStyle.SHORT, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d ah:mm"},
        {FormatStyle.FULL, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5EEEE"},
        {FormatStyle.LONG, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy\u5e74M\u6708d\u65e5"},
        {FormatStyle.MEDIUM, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {FormatStyle.SHORT, null, MinguoChronology.INSTANCE, Locale.CHINESE, "Gy-M-d"},
        {null, FormatStyle.FULL, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2' z"},
        {null, FormatStyle.LONG, MinguoChronology.INSTANCE, Locale.CHINESE, "ahh'\u65f6'mm'\u5206'ss'\u79d2'"},
        {null, FormatStyle.MEDIUM, MinguoChronology.INSTANCE, Locale.CHINESE, "H:mm:ss"},
        {null, FormatStyle.SHORT, MinguoChronology.INSTANCE, Locale.CHINESE, "ah:mm"},
    };
}
 
Example 18
Source File: MyResourcesAsia.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public MyResourcesAsia() {
    super("java.properties", "asia",
          Locale.JAPANESE, Locale.JAPAN, Locale.CHINESE, Locale.TAIWAN,
          new Locale("vi"));
}
 
Example 19
Source File: MessageCatalog.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private Locale getLocale(String localeName) {
    String language, country;
    int index;

    index = localeName.indexOf('_');
    if (index == -1) {
        //
        // Special case the builtin JDK languages
        //
        if (localeName.equals("de"))
            return Locale.GERMAN;
        if (localeName.equals("en"))
            return Locale.ENGLISH;
        if (localeName.equals("fr"))
            return Locale.FRENCH;
        if (localeName.equals("it"))
            return Locale.ITALIAN;
        if (localeName.equals("ja"))
            return Locale.JAPANESE;
        if (localeName.equals("ko"))
            return Locale.KOREAN;
        if (localeName.equals("zh"))
            return Locale.CHINESE;

        language = localeName;
        country = "";
    } else {
        if (localeName.equals("zh_CN"))
            return Locale.SIMPLIFIED_CHINESE;
        if (localeName.equals("zh_TW"))
            return Locale.TRADITIONAL_CHINESE;

        //
        // JDK also has constants for countries:  en_GB, en_US, en_CA,
        // fr_FR, fr_CA, de_DE, ja_JP, ko_KR.  We don't use those.
        //
        language = localeName.substring(0, index);
        country = localeName.substring(index + 1);
    }

    return new Locale(language, country);
}
 
Example 20
Source File: DefaultDelegateMessageBundle.java    From super-cloudops with Apache License 2.0 2 votes vote down vote up
/**
 * Default usage local locale.
 * 
 * @return
 */
protected Locale getSessionLocale() {
	return Locale.CHINESE;
}