Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8204603

Short week days, NaN value and timezone name are inconsistent between CLDR and Java in zh_CN, zh_TW locales.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • 11
    • core-libs
    • master
    • Verified

        JDK version:
        jdk 11 build 12 failed
        jdk 11 build 11 passed.

        With default provider to run below test: "java Test2", Short week days, NaN value and timezone name are inconsistent between CLDR and Java in zh_CN, zh_TW locales.
        For example, in CLDR, short week days in zh_CN is:<day type="sun">周日</day>, but Java output "星期日".

        public class Test2 {

            public static void main(String[] args) throws Exception {
                DateFormatSymbols dfs;
                DateFormat df;
                DecimalFormat decimalf;
                DecimalFormatSymbols decimalfs;
                Locale zh_CN = Locale.forLanguageTag("zh-CN");
                Locale zh_TW = Locale.forLanguageTag("zh-TW");

                System.out.println("DateFormatSymbols.getShortWeekdays:");
                dfs = DateFormatSymbols.getInstance(zh_CN);
                String[] shortDays_zh_CN = dfs.getShortWeekdays();
                System.out.println("locale:zh_CN:" + shortDays_zh_CN[Calendar.SUNDAY]);

                dfs = DateFormatSymbols.getInstance(zh_TW);
                String[] shortDays_zh_TW = dfs.getShortWeekdays();
                System.out.println("locale:zh_TW:" + shortDays_zh_TW[Calendar.SUNDAY]);

                System.out.println("DateFormat.getTimeInstance.format:");
                TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
                long l = 882869989318L;
                df = DateFormat.getTimeInstance(DateFormat.FULL, zh_CN);
                df.setTimeZone(tz);
                String fmt_zh_CN = df.format(new Date(l));
                System.out.println("locale:zh_CN:" + fmt_zh_CN);

                df = DateFormat.getTimeInstance(DateFormat.FULL, zh_TW);
                df.setTimeZone(tz);
                String fmt_zh_TW = df.format(new Date(l));
                System.out.println("locale:zh_TW:" + fmt_zh_TW);

                System.out.println("DecimalFormat.getNaN:");
                decimalf = (DecimalFormat) NumberFormat.getInstance(zh_CN);
                decimalfs = decimalf.getDecimalFormatSymbols();
                String nan_zh_CN = decimalfs.getNaN();
                System.out.println("locale:zh_CN:" + nan_zh_CN);

                decimalf = (DecimalFormat) NumberFormat.getInstance(zh_TW);
                decimalfs = decimalf.getDecimalFormatSymbols();
                String nan_zh_TW = decimalfs.getNaN();
                System.out.println("locale:zh_TW:" + nan_zh_TW);
            }
        }
         
        Except output:
        DateFormatSymbols.getShortWeekdays:
        locale:zh_CN:周日
        locale:zh_TW:週日
        DateFormat.getTimeInstance.format:
        locale:zh_CN:北美太平洋标准时间 上午1:39:49
        locale:zh_TW:上午1:39:49 [太平洋標準時間]
        DecimalFormat.getNaN:
        locale:zh_CN:NaN
        locale:zh_TW:非數值

        Actual output:
        DateFormatSymbols.getShortWeekdays:
        locale:zh_CN:星期日
        locale:zh_TW:星期日
        DateFormat.getTimeInstance.format:
        locale:zh_CN:上午01时39分49秒 PST
        locale:zh_TW:上午01時39分49秒 PST
        DecimalFormat.getNaN:
        locale:zh_CN:?
        locale:zh_TW:?

        Setting CLDR provider explicitly to run above test, "java -Djava.locale.providers=CLDR Test2", it can get expected output.

              rgoel Rachna Goel (Inactive)
              dzhou Dora Zhou (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: