/** * Returns the Sun private Era instance corresponding to this {@code JapaneseEra}. * SEIREKI doesn't have its corresponding one. * * @return the Sun private Era instance for this {@code JapaneseEra}, * or null for SEIREKI. */ sun.util.calendar.Era getPrivateEra() { return ERA_CONFIG[ordinal(eraValue)]; }
/** * Obtains an instance of {@code JapaneseEra} from an {@code int} value. * <p> * The {@link #SHOWA} era that contains 1970-01-01 (ISO calendar system) has the value 1 * Later era is numbered 2 ({@link #HEISEI}). Earlier eras are numbered 0 ({@link #TAISHO}), * -1 ({@link #MEIJI}), only Meiji and later eras are supported. * * @param japaneseEra the era to represent * @return the {@code JapaneseEra} singleton, not null * @throws DateTimeException if the value is invalid */ public static JapaneseEra of(int japaneseEra) { if (japaneseEra < MEIJI.eraValue || japaneseEra + ERA_OFFSET - 1 >= KNOWN_ERAS.length) { throw new DateTimeException("japaneseEra is invalid"); } return KNOWN_ERAS[ordinal(japaneseEra)]; }
String getName() { int index = ordinal(getValue()); return ERA_CONFIG[index].getName(); }
String getAbbreviation() { int index = ordinal(getValue()); if (index == 0) { return ""; } return ERA_CONFIG[index].getAbbreviation(); }
/** * Returns the start date of the era. * @return the start date */ LocalDate endDate() { int ordinal = ordinal(eraValue); JapaneseEra[] eras = values(); if (ordinal >= eras.length - 1) { return LocalDate.MAX; } return eras[ordinal + 1].startDate().minusDays(1); }