60 import static java.time.temporal.ChronoUnit.DAYS;
61 import static java.time.temporal.ChronoUnit.MONTHS;
62 import static java.time.temporal.ChronoUnit.YEARS;
63
64 import java.io.DataInput;
65 import java.io.DataOutput;
66 import java.io.IOException;
67 import java.io.InvalidObjectException;
68 import java.io.ObjectInputStream;
69 import java.io.ObjectStreamException;
70 import java.io.Serializable;
71 import java.time.DateTimeException;
72 import java.time.temporal.ChronoUnit;
73 import java.time.temporal.Temporal;
74 import java.time.temporal.TemporalAccessor;
75 import java.time.temporal.TemporalAmount;
76 import java.time.temporal.TemporalQueries;
77 import java.time.temporal.TemporalUnit;
78 import java.time.temporal.UnsupportedTemporalTypeException;
79 import java.time.temporal.ValueRange;
80 import java.util.Arrays;
81 import java.util.Collections;
82 import java.util.List;
83 import java.util.Objects;
84
85 /**
86 * A period expressed in terms of a standard year-month-day calendar system.
87 * <p>
88 * This class is used by applications seeking to handle dates in non-ISO calendar systems.
89 * For example, the Japanese, Minguo, Thai Buddhist and others.
90 *
91 * @implSpec
92 * This class is immutable nad thread-safe.
93 *
94 * @since 1.8
95 */
96 final class ChronoPeriodImpl
97 implements ChronoPeriod, Serializable {
98 // this class is only used by JDK chronology implementations and makes assumptions based on that fact
99
100 /**
101 * Serialization version.
102 */
103 private static final long serialVersionUID = 57387258289L;
104
105 /**
106 * The set of supported units.
107 */
108 private static final List<TemporalUnit> SUPPORTED_UNITS =
109 Collections.unmodifiableList(Arrays.<TemporalUnit>asList(YEARS, MONTHS, DAYS));
110
111 /**
112 * The chronology.
113 */
114 private final Chronology chrono;
115 /**
116 * The number of years.
117 */
118 final int years;
119 /**
120 * The number of months.
121 */
122 final int months;
123 /**
124 * The number of days.
125 */
126 final int days;
127
128 /**
129 * Creates an instance.
|
60 import static java.time.temporal.ChronoUnit.DAYS;
61 import static java.time.temporal.ChronoUnit.MONTHS;
62 import static java.time.temporal.ChronoUnit.YEARS;
63
64 import java.io.DataInput;
65 import java.io.DataOutput;
66 import java.io.IOException;
67 import java.io.InvalidObjectException;
68 import java.io.ObjectInputStream;
69 import java.io.ObjectStreamException;
70 import java.io.Serializable;
71 import java.time.DateTimeException;
72 import java.time.temporal.ChronoUnit;
73 import java.time.temporal.Temporal;
74 import java.time.temporal.TemporalAccessor;
75 import java.time.temporal.TemporalAmount;
76 import java.time.temporal.TemporalQueries;
77 import java.time.temporal.TemporalUnit;
78 import java.time.temporal.UnsupportedTemporalTypeException;
79 import java.time.temporal.ValueRange;
80 import java.util.List;
81 import java.util.Objects;
82
83 /**
84 * A period expressed in terms of a standard year-month-day calendar system.
85 * <p>
86 * This class is used by applications seeking to handle dates in non-ISO calendar systems.
87 * For example, the Japanese, Minguo, Thai Buddhist and others.
88 *
89 * @implSpec
90 * This class is immutable nad thread-safe.
91 *
92 * @since 1.8
93 */
94 final class ChronoPeriodImpl
95 implements ChronoPeriod, Serializable {
96 // this class is only used by JDK chronology implementations and makes assumptions based on that fact
97
98 /**
99 * Serialization version.
100 */
101 private static final long serialVersionUID = 57387258289L;
102
103 /**
104 * The set of supported units.
105 */
106 private static final List<TemporalUnit> SUPPORTED_UNITS = List.of(YEARS, MONTHS, DAYS);
107
108 /**
109 * The chronology.
110 */
111 private final Chronology chrono;
112 /**
113 * The number of years.
114 */
115 final int years;
116 /**
117 * The number of months.
118 */
119 final int months;
120 /**
121 * The number of days.
122 */
123 final int days;
124
125 /**
126 * Creates an instance.
|