118 * This class is immutable and thread-safe.
119 *
120 * @since 1.8
121 */
122 public final class JapaneseChronology extends AbstractChronology implements Serializable {
123
124 static final LocalGregorianCalendar JCAL =
125 (LocalGregorianCalendar) CalendarSystem.forName("japanese");
126
127 // Locale for creating a JapaneseImpericalCalendar.
128 static final Locale LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese");
129
130 /**
131 * Singleton instance for Japanese chronology.
132 */
133 public static final JapaneseChronology INSTANCE = new JapaneseChronology();
134
135 /**
136 * Serialization version.
137 */
138 private static final long serialVersionUID = 459996390165777884L;
139
140 //-----------------------------------------------------------------------
141 /**
142 * Restricted constructor.
143 */
144 private JapaneseChronology() {
145 }
146
147 //-----------------------------------------------------------------------
148 /**
149 * Gets the ID of the chronology - 'Japanese'.
150 * <p>
151 * The ID uniquely identifies the {@code Chronology}.
152 * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}.
153 *
154 * @return the chronology ID - 'Japanese'
155 * @see #getCalendarType()
156 */
157 @Override
499 long days = Math.subtractExact(fieldValues.remove(DAY_OF_YEAR), 1);
500 return dateYearDay(y, 1).plus(days, DAYS);
501 }
502 int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR), DAY_OF_YEAR);
503 return dateYearDay(era, yoe, doy); // smart is same as strict
504 }
505
506 //-----------------------------------------------------------------------
507 /**
508 * Writes the Chronology using a
509 * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
510 * @serialData
511 * <pre>
512 * out.writeByte(1); // identifies a Chronology
513 * out.writeUTF(getId());
514 * </pre>
515 *
516 * @return the instance of {@code Ser}, not null
517 */
518 @Override
519 Object writeReplace() {
520 return super.writeReplace();
521 }
522
523 /**
524 * Defend against malicious streams.
525 *
526 * @param s the stream to read
527 * @throws InvalidObjectException always
528 */
529 private void readObject(ObjectInputStream s) throws InvalidObjectException {
530 throw new InvalidObjectException("Deserialization via serialization delegate");
531 }
532 }
|
118 * This class is immutable and thread-safe.
119 *
120 * @since 1.8
121 */
122 public final class JapaneseChronology extends AbstractChronology implements Serializable {
123
124 static final LocalGregorianCalendar JCAL =
125 (LocalGregorianCalendar) CalendarSystem.forName("japanese");
126
127 // Locale for creating a JapaneseImpericalCalendar.
128 static final Locale LOCALE = Locale.forLanguageTag("ja-JP-u-ca-japanese");
129
130 /**
131 * Singleton instance for Japanese chronology.
132 */
133 public static final JapaneseChronology INSTANCE = new JapaneseChronology();
134
135 /**
136 * Serialization version.
137 */
138 @java.io.Serial
139 private static final long serialVersionUID = 459996390165777884L;
140
141 //-----------------------------------------------------------------------
142 /**
143 * Restricted constructor.
144 */
145 private JapaneseChronology() {
146 }
147
148 //-----------------------------------------------------------------------
149 /**
150 * Gets the ID of the chronology - 'Japanese'.
151 * <p>
152 * The ID uniquely identifies the {@code Chronology}.
153 * It can be used to lookup the {@code Chronology} using {@link Chronology#of(String)}.
154 *
155 * @return the chronology ID - 'Japanese'
156 * @see #getCalendarType()
157 */
158 @Override
500 long days = Math.subtractExact(fieldValues.remove(DAY_OF_YEAR), 1);
501 return dateYearDay(y, 1).plus(days, DAYS);
502 }
503 int doy = range(DAY_OF_YEAR).checkValidIntValue(fieldValues.remove(DAY_OF_YEAR), DAY_OF_YEAR);
504 return dateYearDay(era, yoe, doy); // smart is same as strict
505 }
506
507 //-----------------------------------------------------------------------
508 /**
509 * Writes the Chronology using a
510 * <a href="{@docRoot}/serialized-form.html#java.time.chrono.Ser">dedicated serialized form</a>.
511 * @serialData
512 * <pre>
513 * out.writeByte(1); // identifies a Chronology
514 * out.writeUTF(getId());
515 * </pre>
516 *
517 * @return the instance of {@code Ser}, not null
518 */
519 @Override
520 @java.io.Serial
521 Object writeReplace() {
522 return super.writeReplace();
523 }
524
525 /**
526 * Defend against malicious streams.
527 *
528 * @param s the stream to read
529 * @throws InvalidObjectException always
530 */
531 @java.io.Serial
532 private void readObject(ObjectInputStream s) throws InvalidObjectException {
533 throw new InvalidObjectException("Deserialization via serialization delegate");
534 }
535 }
|