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

Calendar.getDisplayNames inconsistent with DateFormatSymbols

    Details

    • Subcomponent:
    • Resolved In Build:
      b155
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        java version "9-ea"
        Java(TM) SE Runtime Environment (build 9-ea+137)
        Java HotSpot(TM) 64-Bit Server VM (build 9-ea+137, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Darwin McBookAir 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64


        A DESCRIPTION OF THE PROBLEM :
        The results of DateFormatSymbols.getEras() is inconsistent with results of Calendar.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, locale)

        For Gregorian calendars (not thai and japanese locales), I expect that the map returned from getDisplayNames() contains all of the values returned from DateFormatSymbols.getEras().

        However, this is not the case for "qu", "no", and "zh" locales.

        REGRESSION. Last worked in version 8u92

        ADDITIONAL REGRESSION INFORMATION:
        java version "1.8.0_92"
        Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
        Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)


        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the unit test case below.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        Locale: ja_JP_JP_#u-ca-japanese name: ??? not in map
        Locale: th_TH name: ?.?. not in map
        Locale: th_TH_TH_#u-nu-thai name: ?.?. not in map
        ACTUAL -
        Locale: qu_EC name: not in map
        Locale: no name: BC not in map
        Locale: no name: AD not in map
        Locale: qu name: not in map
        Locale: qu_PE name: not in map
        Locale: th_TH_TH_#u-nu-thai name: ปีก่อนคริสต์กาลที่ not in map
        Locale: th_TH_TH_#u-nu-thai name: ค.ศ. not in map
        Locale: no_NO name: BC not in map
        Locale: no_NO name: AD not in map
        Locale: qu_BO name: not in map
        Locale: ja_JP_JP_#u-ca-japanese name: 紀元前 not in map
        Locale: zh_HK name: 西元前 not in map
        Locale: zh_HK name: 西元 not in map
        Locale: th_TH name: ปีก่อนคริสต์กาลที่ not in map
        Locale: th_TH name: ค.ศ. not in map


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------

            @Test
            public void testDisplayNames() {
                for(final Locale locale : Locale.getAvailableLocales()) {
                    Calendar cal = Calendar.getInstance(locale);
                    Map<String,Integer> names= cal.getDisplayNames(Calendar.ERA, Calendar.ALL_STYLES, locale);

                    DateFormatSymbols symbols = new DateFormatSymbols(locale);
                    String[] eras = symbols.getEras();
                    for(String era : eras) {
                        if(!names.containsKey(era)) {
                        System.err.println("Locale: "+locale+" name: "+era+" not in map");
                        }
                    }
                }
            }

        ---------- END SOURCE ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rgoel Rachna Goel (Inactive)
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: