JDK-8171049 : Era.getDisplayName doesn't work with non-IsoChronology
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.time
  • Affected Version: 8,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2016-12-10
  • Updated: 2019-04-23
  • Resolved: 2017-08-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10 JDK 8 Other
10 b22Fixed 8u201Fixed openjdk8u212Fixed
Related Reports
CSR :  
Description
The default implementation of Era.getDisplayName doesn't work  with non-IsoChronology because DateTimeFormatterBuilder.TextPrinterParser.format fails to get the Chronology of the Era.
Comments
Each subclass of Era should implement getDisplayName(), e.g., for JapaneseEra, diff -r 8860e24659c3 src/java.base/share/classes/java/time/chrono/JapaneseEra.java --- a/src/java.base/share/classes/java/time/chrono/JapaneseEra.java +++ b/src/java.base/share/classes/java/time/chrono/JapaneseEra.java @@ -73,6 +73,7 @@ import java.io.Serializable; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; import java.time.temporal.TemporalField; @@ -253,7 +254,8 @@ Objects.requireNonNull(locale, "locale"); return style.asNormal() == TextStyle.NARROW ? getAbbreviation() : getName(); } - return Era.super.getDisplayName(style, locale); + return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale) + .withChronology(JapaneseChronology.INSTANCE).format(since); } //-----------------------------------------------------------------------
23-08-2017

Found during https://bugs.openjdk.java.net/browse/JDK-8054214
14-12-2016