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

Some of the java.time.chrono.Eras return empty display name for some styles and locales

    XMLWordPrintable

Details

    • b15
    • Verified

    Description

      Some of the java.time.chrono.Eras return empty display name for some styles and locales.
      https://download.java.net/java/early_access/jdk14/docs/api/java.base/java/time/chrono/Era.html#getDisplayName(java.time.format.TextStyle,java.util.Locale)
      Specification:
      "Gets the textual representation of this era. This returns the textual name used to identify the era, suitable for presentation to the user. The parameters control the style of the returned text and the locale. If no textual mapping is found then the numeric value is returned."

      Consider the following code sample iterating over eras, text styles and avail locales:

      import java.time.chrono.*;
      import java.time.format.TextStyle;
      import java.util.*;

      public class GetDisplayNameEmpty {
          public static void main(String[] args) {
              List<Era> erasList = new ArrayList<>();
              erasList.addAll(Arrays.asList(JapaneseEra.values()));
              erasList.addAll(Arrays.asList(HijrahEra.values()));
              erasList.addAll(Arrays.asList(IsoEra.values()));
              erasList.addAll(Arrays.asList(ThaiBuddhistEra.values()));
              erasList.addAll(Arrays.asList(MinguoEra.values()));
              int nonEmptyCases = 0;
              int emptyCases = 0;
              for (Era era : erasList) {
                  for (TextStyle style : TextStyle.values()) {
                      for (Locale locale : Locale.getAvailableLocales()) {
                          String displayName = era.getDisplayName(style, locale);
                          if (displayName.isEmpty()) {
                              System.out.println("era.getDisplayName(style, locale) is empty for era = " + era + ", style = " + style + ", locale = " + locale);
                              emptyCases++;
                          } else {
                              nonEmptyCases++;
                          }
                      }
                  }
              }
              System.out.println("Non empty: " + nonEmptyCases + ", empty: " + emptyCases);
          }
      }

      It would print out something like:

      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = el
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = fa
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = uk
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = el
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = uk
      era.getDisplayName(style, locale) is empty for era = Meiji, style = FULL_STANDALONE, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = el
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = fa
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = uk
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = el
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = uk
      era.getDisplayName(style, locale) is empty for era = Meiji, style = SHORT_STANDALONE, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = NARROW, locale = fa
      era.getDisplayName(style, locale) is empty for era = Meiji, style = NARROW, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Meiji, style = NARROW, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Meiji, style = NARROW_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Meiji, style = NARROW_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Meiji, style = NARROW_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = el
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = fa
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = uk
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = el
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = uk
      era.getDisplayName(style, locale) is empty for era = Taisho, style = FULL_STANDALONE, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = el
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = fa
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = uk
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = el
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = uk
      era.getDisplayName(style, locale) is empty for era = Taisho, style = SHORT_STANDALONE, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = NARROW, locale = fa
      era.getDisplayName(style, locale) is empty for era = Taisho, style = NARROW, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Taisho, style = NARROW, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Taisho, style = NARROW_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Taisho, style = NARROW_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Taisho, style = NARROW_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = el
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = fa
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = uk
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = el
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = uk
      era.getDisplayName(style, locale) is empty for era = Showa, style = FULL_STANDALONE, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = el
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = fa
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = uk
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = el
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = el_CY
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = uk_UA
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = uk
      era.getDisplayName(style, locale) is empty for era = Showa, style = SHORT_STANDALONE, locale = el_GR
      era.getDisplayName(style, locale) is empty for era = Showa, style = NARROW, locale = fa
      era.getDisplayName(style, locale) is empty for era = Showa, style = NARROW, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Showa, style = NARROW, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = Showa, style = NARROW_STANDALONE, locale = fa
      era.getDisplayName(style, locale) is empty for era = Showa, style = NARROW_STANDALONE, locale = fa_AF
      era.getDisplayName(style, locale) is empty for era = Showa, style = NARROW_STANDALONE, locale = fa_IR
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW, locale = nb_SJ
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW, locale = no
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW, locale = nb_NO
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW, locale = no_NO
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW, locale = nb
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW_STANDALONE, locale = nb_SJ
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW_STANDALONE, locale = no
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW_STANDALONE, locale = nb_NO
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW_STANDALONE, locale = no_NO
      era.getDisplayName(style, locale) is empty for era = BEFORE_ROC, style = NARROW_STANDALONE, locale = nb
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = in
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = lo
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = vi_VN
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = lo_LA
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = in_ID
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = ja_JP_JP_#u-ca-japanese
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = ja_JP
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = ja
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL, locale = vi
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = in
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = lo
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = vi_VN
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = lo_LA
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = in_ID
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = ja_JP_JP_#u-ca-japanese
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = ja_JP
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = ja
      era.getDisplayName(style, locale) is empty for era = ROC, style = FULL_STANDALONE, locale = vi
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT, locale = in
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT, locale = lo
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT, locale = vi_VN
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT, locale = lo_LA
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT, locale = in_ID
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT, locale = vi
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT_STANDALONE, locale = in
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT_STANDALONE, locale = lo
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT_STANDALONE, locale = vi_VN
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT_STANDALONE, locale = lo_LA
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT_STANDALONE, locale = in_ID
      era.getDisplayName(style, locale) is empty for era = ROC, style = SHORT_STANDALONE, locale = vi
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW, locale = in
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW, locale = lo
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW, locale = vi_VN
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW, locale = lo_LA
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW, locale = in_ID
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW, locale = vi
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW_STANDALONE, locale = in
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW_STANDALONE, locale = lo
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW_STANDALONE, locale = vi_VN
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW_STANDALONE, locale = lo_LA
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW_STANDALONE, locale = in_ID
      era.getDisplayName(style, locale) is empty for era = ROC, style = NARROW_STANDALONE, locale = vi
      Non empty: 55490, empty: 166


      Attachments

        Activity

          People

            naoto Naoto Sato
            dbessono Dmitry Bessonov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: