/** * Reconstitutes this object from a stream. * * @param stream object input stream */ private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); this.era = JapaneseEra.from(isoDate); int yearOffset = this.era.startDate().getYear() - 1; this.yearOfEra = isoDate.getYear() - yearOffset; }
/** * Creates an instance from an ISO date. * * @param isoDate the standard local date, validated not null */ JapaneseDate(LocalDate isoDate) { if (isoDate.isBefore(MIN_DATE)) { throw new DateTimeException("Minimum supported date is January 1st Meiji 6"); } this.era = JapaneseEra.from(isoDate); int yearOffset = this.era.startDate().getYear() - 1; this.yearOfEra = isoDate.getYear() - yearOffset; this.isoDate = isoDate; }