< prev index next >
src/java.base/share/classes/java/time/chrono/HijrahEra.java
Print this page
rev 17640 : [mq]: 8171049
*** 1,7 ****
/*
! * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 62,75 ****
--- 62,78 ----
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.time.temporal.ChronoField;
import java.time.temporal.TemporalField;
import java.time.temporal.UnsupportedTemporalTypeException;
import java.time.temporal.ValueRange;
+ import java.util.Locale;
/**
* An era in the Hijrah calendar system.
* <p>
* The Hijrah calendar system has only one era covering the
*** 153,158 ****
--- 156,175 ----
return ValueRange.of(1, 1);
}
return Era.super.range(field);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @param style {@inheritDoc}
+ * @param locale {@inheritDoc}
+ */
+ @Override
+ public String getDisplayName(TextStyle style, Locale locale) {
+ return new DateTimeFormatterBuilder()
+ .appendText(ERA, style)
+ .toFormatter(locale)
+ .withChronology(HijrahChronology.INSTANCE)
+ .format(HijrahDate.now());
+ }
}
< prev index next >