235 *
236 * @return an array of JapaneseEras
237 */
238 public static JapaneseEra[] values() {
239 return Arrays.copyOf(KNOWN_ERAS, KNOWN_ERAS.length);
240 }
241
242 /**
243 * Gets the textual representation of this era.
244 * <p>
245 * This returns the textual name used to identify the era,
246 * suitable for presentation to the user.
247 * The parameters control the style of the returned text and the locale.
248 * <p>
249 * If no textual mapping is found then the {@link #getValue() numeric value}
250 * is returned.
251 *
252 * @param style the style of the text required, not null
253 * @param locale the locale to use, not null
254 * @return the text value of the era, not null
255 * @since 9
256 */
257 @Override
258 public String getDisplayName(TextStyle style, Locale locale) {
259 // If this JapaneseEra is a supplemental one, obtain the name from
260 // the era definition.
261 if (getValue() > N_ERA_CONSTANTS - ERA_OFFSET) {
262 Objects.requireNonNull(locale, "locale");
263 return style.asNormal() == TextStyle.NARROW ? getAbbreviation() : getName();
264 }
265 return Era.super.getDisplayName(style, locale);
266 }
267
268 //-----------------------------------------------------------------------
269 /**
270 * Obtains an instance of {@code JapaneseEra} from a date.
271 *
272 * @param date the date, not null
273 * @return the Era singleton, never null
274 */
275 static JapaneseEra from(LocalDate date) {
|
235 *
236 * @return an array of JapaneseEras
237 */
238 public static JapaneseEra[] values() {
239 return Arrays.copyOf(KNOWN_ERAS, KNOWN_ERAS.length);
240 }
241
242 /**
243 * Gets the textual representation of this era.
244 * <p>
245 * This returns the textual name used to identify the era,
246 * suitable for presentation to the user.
247 * The parameters control the style of the returned text and the locale.
248 * <p>
249 * If no textual mapping is found then the {@link #getValue() numeric value}
250 * is returned.
251 *
252 * @param style the style of the text required, not null
253 * @param locale the locale to use, not null
254 * @return the text value of the era, not null
255 */
256 @Override
257 public String getDisplayName(TextStyle style, Locale locale) {
258 // If this JapaneseEra is a supplemental one, obtain the name from
259 // the era definition.
260 if (getValue() > N_ERA_CONSTANTS - ERA_OFFSET) {
261 Objects.requireNonNull(locale, "locale");
262 return style.asNormal() == TextStyle.NARROW ? getAbbreviation() : getName();
263 }
264 return Era.super.getDisplayName(style, locale);
265 }
266
267 //-----------------------------------------------------------------------
268 /**
269 * Obtains an instance of {@code JapaneseEra} from a date.
270 *
271 * @param date the date, not null
272 * @return the Era singleton, never null
273 */
274 static JapaneseEra from(LocalDate date) {
|