< prev index next >

src/java.base/share/classes/java/time/chrono/MinguoEra.java

Print this page
rev 17640 : [mq]: 8171049

@@ -59,11 +59,16 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 package java.time.chrono;
 
+import static java.time.temporal.ChronoField.ERA;
+
 import java.time.DateTimeException;
+import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.TextStyle;
+import java.util.Locale;
 
 /**
  * An era in the Minguo calendar system.
  * <p>
  * The Minguo calendar system has two eras.

@@ -151,6 +156,21 @@
     @Override
     public int getValue() {
         return ordinal();
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @param style {@inheritDoc}
+     * @param locale {@inheritDoc}
+     */
+    @Override
+    public String getDisplayName(TextStyle style, Locale locale) {
+        return new DateTimeFormatterBuilder()
+            .appendText(ERA, style)
+            .toFormatter(locale)
+            .withChronology(MinguoChronology.INSTANCE)
+            .format(this == ROC ? MinguoDate.of(1, 1, 1) : MinguoDate.of(0, 1, 1));
+    }
+
 }
< prev index next >