mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
java.time: get rid of serialization code
This commit is contained in:
parent
051c3bb227
commit
5d630ae551
|
@ -398,7 +398,6 @@ public abstract class Clock {
|
||||||
* {@link System#currentTimeMillis()}.
|
* {@link System#currentTimeMillis()}.
|
||||||
*/
|
*/
|
||||||
static final class SystemClock extends Clock implements Serializable {
|
static final class SystemClock extends Clock implements Serializable {
|
||||||
private static final long serialVersionUID = 6740630888130243051L;
|
|
||||||
private final ZoneId zone;
|
private final ZoneId zone;
|
||||||
|
|
||||||
SystemClock(ZoneId zone) {
|
SystemClock(ZoneId zone) {
|
||||||
|
@ -446,7 +445,6 @@ public abstract class Clock {
|
||||||
* This is typically used for testing.
|
* This is typically used for testing.
|
||||||
*/
|
*/
|
||||||
static final class FixedClock extends Clock implements Serializable {
|
static final class FixedClock extends Clock implements Serializable {
|
||||||
private static final long serialVersionUID = 7430389292664866958L;
|
|
||||||
private final Instant instant;
|
private final Instant instant;
|
||||||
private final ZoneId zone;
|
private final ZoneId zone;
|
||||||
|
|
||||||
|
@ -496,7 +494,6 @@ public abstract class Clock {
|
||||||
* Implementation of a clock that adds an offset to an underlying clock.
|
* Implementation of a clock that adds an offset to an underlying clock.
|
||||||
*/
|
*/
|
||||||
static final class OffsetClock extends Clock implements Serializable {
|
static final class OffsetClock extends Clock implements Serializable {
|
||||||
private static final long serialVersionUID = 2007484719125426256L;
|
|
||||||
private final Clock baseClock;
|
private final Clock baseClock;
|
||||||
private final Duration offset;
|
private final Duration offset;
|
||||||
|
|
||||||
|
@ -546,7 +543,6 @@ public abstract class Clock {
|
||||||
* Implementation of a clock that adds an offset to an underlying clock.
|
* Implementation of a clock that adds an offset to an underlying clock.
|
||||||
*/
|
*/
|
||||||
static final class TickClock extends Clock implements Serializable {
|
static final class TickClock extends Clock implements Serializable {
|
||||||
private static final long serialVersionUID = 6504659149906368850L;
|
|
||||||
private final Clock baseClock;
|
private final Clock baseClock;
|
||||||
private final long tickNanos;
|
private final long tickNanos;
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,6 @@ package org.threeten.bp;
|
||||||
*/
|
*/
|
||||||
public class DateTimeException extends RuntimeException {
|
public class DateTimeException extends RuntimeException {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -1632418723876261839L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new date-time exception with the specified message.
|
* Constructs a new date-time exception with the specified message.
|
||||||
*
|
*
|
||||||
|
|
|
@ -39,11 +39,6 @@ import static org.threeten.bp.temporal.ChronoUnit.DAYS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.SECONDS;
|
import static org.threeten.bp.temporal.ChronoUnit.SECONDS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
@ -98,10 +93,6 @@ public final class Duration
|
||||||
* Constant for a duration of zero.
|
* Constant for a duration of zero.
|
||||||
*/
|
*/
|
||||||
public static final Duration ZERO = new Duration(0, 0);
|
public static final Duration ZERO = new Duration(0, 0);
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 3078945930695997490L;
|
|
||||||
/**
|
/**
|
||||||
* Constant for nanos per second.
|
* Constant for nanos per second.
|
||||||
*/
|
*/
|
||||||
|
@ -1232,29 +1223,5 @@ public final class Duration
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.DURATION_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeLong(seconds);
|
|
||||||
out.writeInt(nanos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Duration readExternal(DataInput in) throws IOException {
|
|
||||||
long seconds = in.readLong();
|
|
||||||
int nanos = in.readInt();
|
|
||||||
return Duration.ofSeconds(seconds, nanos);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,6 @@ import static org.threeten.bp.temporal.ChronoField.NANO_OF_SECOND;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.DAYS;
|
import static org.threeten.bp.temporal.ChronoUnit.DAYS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -201,10 +196,6 @@ public final class Instant
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -665713676816604388L;
|
|
||||||
/**
|
/**
|
||||||
* Constant for nanos per second.
|
* Constant for nanos per second.
|
||||||
*/
|
*/
|
||||||
|
@ -1160,30 +1151,4 @@ public final class Instant
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return DateTimeFormatter.ISO_INSTANT.format(this);
|
return DateTimeFormatter.ISO_INSTANT.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.INSTANT_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeLong(seconds);
|
|
||||||
out.writeInt(nanos);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Instant readExternal(DataInput in) throws IOException {
|
|
||||||
long seconds = in.readLong();
|
|
||||||
int nanos = in.readInt();
|
|
||||||
return Instant.ofEpochSecond(seconds, nanos);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,6 @@ import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
||||||
import static org.threeten.bp.temporal.ChronoField.PROLEPTIC_MONTH;
|
import static org.threeten.bp.temporal.ChronoField.PROLEPTIC_MONTH;
|
||||||
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -113,10 +108,6 @@ public final class LocalDate
|
||||||
*/
|
*/
|
||||||
public static final LocalDate MAX = LocalDate.of(Year.MAX_VALUE, 12, 31);
|
public static final LocalDate MAX = LocalDate.of(Year.MAX_VALUE, 12, 31);
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 2942565459149668126L;
|
|
||||||
/**
|
/**
|
||||||
* The number of days in a 400 year cycle.
|
* The number of days in a 400 year cycle.
|
||||||
*/
|
*/
|
||||||
|
@ -1850,32 +1841,4 @@ public final class LocalDate
|
||||||
public String format(DateTimeFormatter formatter) {
|
public String format(DateTimeFormatter formatter) {
|
||||||
return super.format(formatter);
|
return super.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.LOCAL_DATE_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeInt(year);
|
|
||||||
out.writeByte(month);
|
|
||||||
out.writeByte(day);
|
|
||||||
}
|
|
||||||
|
|
||||||
static LocalDate readExternal(DataInput in) throws IOException {
|
|
||||||
int year = in.readInt();
|
|
||||||
int month = in.readByte();
|
|
||||||
int dayOfMonth = in.readByte();
|
|
||||||
return LocalDate.of(year, month, dayOfMonth);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,6 @@ import static org.threeten.bp.LocalTime.NANOS_PER_MINUTE;
|
||||||
import static org.threeten.bp.LocalTime.NANOS_PER_SECOND;
|
import static org.threeten.bp.LocalTime.NANOS_PER_SECOND;
|
||||||
import static org.threeten.bp.LocalTime.SECONDS_PER_DAY;
|
import static org.threeten.bp.LocalTime.SECONDS_PER_DAY;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -1814,30 +1809,4 @@ public final class LocalDateTime
|
||||||
public String format(DateTimeFormatter formatter) {
|
public String format(DateTimeFormatter formatter) {
|
||||||
return super.format(formatter);
|
return super.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.LOCAL_DATE_TIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
date.writeExternal(out);
|
|
||||||
time.writeExternal(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static LocalDateTime readExternal(DataInput in) throws IOException {
|
|
||||||
LocalDate date = LocalDate.readExternal(in);
|
|
||||||
LocalTime time = LocalTime.readExternal(in);
|
|
||||||
return LocalDateTime.of(date, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,6 @@ import static org.threeten.bp.temporal.ChronoField.SECOND_OF_DAY;
|
||||||
import static org.threeten.bp.temporal.ChronoField.SECOND_OF_MINUTE;
|
import static org.threeten.bp.temporal.ChronoField.SECOND_OF_MINUTE;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -177,11 +172,6 @@ public final class LocalTime
|
||||||
*/
|
*/
|
||||||
static final long NANOS_PER_DAY = NANOS_PER_HOUR * HOURS_PER_DAY;
|
static final long NANOS_PER_DAY = NANOS_PER_HOUR * HOURS_PER_DAY;
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 6414437269572265201L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The hour.
|
* The hour.
|
||||||
*/
|
*/
|
||||||
|
@ -1503,64 +1493,4 @@ public final class LocalTime
|
||||||
Objects.requireNonNull(formatter, "formatter");
|
Objects.requireNonNull(formatter, "formatter");
|
||||||
return formatter.format(this);
|
return formatter.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.LOCAL_TIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
if (nano == 0) {
|
|
||||||
if (second == 0) {
|
|
||||||
if (minute == 0) {
|
|
||||||
out.writeByte(~hour);
|
|
||||||
} else {
|
|
||||||
out.writeByte(hour);
|
|
||||||
out.writeByte(~minute);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.writeByte(hour);
|
|
||||||
out.writeByte(minute);
|
|
||||||
out.writeByte(~second);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
out.writeByte(hour);
|
|
||||||
out.writeByte(minute);
|
|
||||||
out.writeByte(second);
|
|
||||||
out.writeInt(nano);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static LocalTime readExternal(DataInput in) throws IOException {
|
|
||||||
int hour = in.readByte();
|
|
||||||
int minute = 0;
|
|
||||||
int second = 0;
|
|
||||||
int nano = 0;
|
|
||||||
if (hour < 0) {
|
|
||||||
hour = ~hour;
|
|
||||||
} else {
|
|
||||||
minute = in.readByte();
|
|
||||||
if (minute < 0) {
|
|
||||||
minute = ~minute;
|
|
||||||
} else {
|
|
||||||
second = in.readByte();
|
|
||||||
if (second < 0) {
|
|
||||||
second = ~second;
|
|
||||||
} else {
|
|
||||||
nano = in.readInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return LocalTime.of(hour, minute, second, nano);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,11 +34,6 @@ package org.threeten.bp;
|
||||||
import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH;
|
import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH;
|
||||||
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -702,30 +697,4 @@ public final class MonthDay
|
||||||
Objects.requireNonNull(formatter, "formatter");
|
Objects.requireNonNull(formatter, "formatter");
|
||||||
return formatter.format(this);
|
return formatter.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.MONTH_DAY_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(month);
|
|
||||||
out.writeByte(day);
|
|
||||||
}
|
|
||||||
|
|
||||||
static MonthDay readExternal(DataInput in) throws IOException {
|
|
||||||
byte month = in.readByte();
|
|
||||||
byte day = in.readByte();
|
|
||||||
return MonthDay.of(month, day);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,6 @@ import static org.threeten.bp.temporal.ChronoField.NANO_OF_DAY;
|
||||||
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -134,11 +129,6 @@ public final class OffsetDateTime
|
||||||
private static final Comparator<OffsetDateTime> INSTANT_COMPARATOR =
|
private static final Comparator<OffsetDateTime> INSTANT_COMPARATOR =
|
||||||
Comparator.comparingLong(OffsetDateTime::toEpochSecond).thenComparingInt(OffsetDateTime::getNano);
|
Comparator.comparingLong(OffsetDateTime::toEpochSecond).thenComparingInt(OffsetDateTime::getNano);
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 2287754244819255394L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The local date-time.
|
* The local date-time.
|
||||||
*/
|
*/
|
||||||
|
@ -1780,30 +1770,4 @@ public final class OffsetDateTime
|
||||||
Objects.requireNonNull(formatter, "formatter");
|
Objects.requireNonNull(formatter, "formatter");
|
||||||
return formatter.format(this);
|
return formatter.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.OFFSET_DATE_TIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
dateTime.writeExternal(out);
|
|
||||||
offset.writeExternal(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OffsetDateTime readExternal(DataInput in) throws IOException {
|
|
||||||
LocalDateTime dateTime = LocalDateTime.readExternal(in);
|
|
||||||
ZoneOffset offset = ZoneOffset.readExternal(in);
|
|
||||||
return OffsetDateTime.of(dateTime, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,11 +39,6 @@ import static org.threeten.bp.temporal.ChronoField.NANO_OF_DAY;
|
||||||
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
import static org.threeten.bp.temporal.ChronoUnit.NANOS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -106,11 +101,6 @@ public final class OffsetTime
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 7264499704384272492L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The local date-time.
|
* The local date-time.
|
||||||
*/
|
*/
|
||||||
|
@ -1285,30 +1275,4 @@ public final class OffsetTime
|
||||||
Objects.requireNonNull(formatter, "formatter");
|
Objects.requireNonNull(formatter, "formatter");
|
||||||
return formatter.format(this);
|
return formatter.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.OFFSET_TIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
time.writeExternal(out);
|
|
||||||
offset.writeExternal(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static OffsetTime readExternal(DataInput in) throws IOException {
|
|
||||||
LocalTime time = LocalTime.readExternal(in);
|
|
||||||
ZoneOffset offset = ZoneOffset.readExternal(in);
|
|
||||||
return OffsetTime.of(time, offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,6 @@ public final class Period
|
||||||
* A constant for a period of zero.
|
* A constant for a period of zero.
|
||||||
*/
|
*/
|
||||||
public static final Period ZERO = new Period(0, 0, 0);
|
public static final Period ZERO = new Period(0, 0, 0);
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -8290556941213247973L;
|
|
||||||
/**
|
/**
|
||||||
* The pattern for parsing.
|
* The pattern for parsing.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,211 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* * Neither the name of JSR-310 nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package org.threeten.bp;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.Externalizable;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidClassException;
|
|
||||||
import java.io.ObjectInput;
|
|
||||||
import java.io.ObjectOutput;
|
|
||||||
import java.io.StreamCorruptedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shared serialization delegate for this package.
|
|
||||||
*
|
|
||||||
* <h4>Implementation notes</h4>
|
|
||||||
* This class wraps the object being serialized, and takes a byte representing the type of the class to
|
|
||||||
* be serialized. This byte can also be used for versioning the serialization format. In this case another
|
|
||||||
* byte flag would be used in order to specify an alternative version of the type format.
|
|
||||||
* For example {@code LOCAL_DATE_TYPE_VERSION_2 = 21}.
|
|
||||||
* <p>
|
|
||||||
* In order to serialise the object it writes its byte and then calls back to the appropriate class where
|
|
||||||
* the serialisation is performed. In order to deserialise the object it read in the type byte, switching
|
|
||||||
* in order to select which class to call back into.
|
|
||||||
* <p>
|
|
||||||
* The serialisation format is determined on a per class basis. In the case of field based classes each
|
|
||||||
* of the fields is written out with an appropriate size format in descending order of the field's size. For
|
|
||||||
* example in the case of {@link LocalDate} year is written before month. Composite classes, such as
|
|
||||||
* {@link LocalDateTime} are serialised as one object.
|
|
||||||
* <p>
|
|
||||||
* This class is mutable and should be created once per serialization.
|
|
||||||
*
|
|
||||||
* @serial include
|
|
||||||
*/
|
|
||||||
final class Ser implements Externalizable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -7683839454370182990L;
|
|
||||||
|
|
||||||
static final byte DURATION_TYPE = 1;
|
|
||||||
static final byte INSTANT_TYPE = 2;
|
|
||||||
static final byte LOCAL_DATE_TYPE = 3;
|
|
||||||
static final byte LOCAL_DATE_TIME_TYPE = 4;
|
|
||||||
static final byte LOCAL_TIME_TYPE = 5;
|
|
||||||
static final byte ZONED_DATE_TIME_TYPE = 6;
|
|
||||||
static final byte ZONE_REGION_TYPE = 7;
|
|
||||||
static final byte ZONE_OFFSET_TYPE = 8;
|
|
||||||
|
|
||||||
static final byte MONTH_DAY_TYPE = 64;
|
|
||||||
static final byte OFFSET_TIME_TYPE = 66;
|
|
||||||
static final byte YEAR_TYPE = 67;
|
|
||||||
static final byte YEAR_MONTH_TYPE = 68;
|
|
||||||
static final byte OFFSET_DATE_TIME_TYPE = 69;
|
|
||||||
|
|
||||||
/** The type being serialized. */
|
|
||||||
private byte type;
|
|
||||||
/** The object being serialized. */
|
|
||||||
private Object object;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for deserialization.
|
|
||||||
*/
|
|
||||||
public Ser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an instance for serialization.
|
|
||||||
*
|
|
||||||
* @param type the type
|
|
||||||
* @param object the object
|
|
||||||
*/
|
|
||||||
Ser(byte type, Object object) {
|
|
||||||
this.type = type;
|
|
||||||
this.object = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Implements the {@code Externalizable} interface to write the object.
|
|
||||||
*
|
|
||||||
* @param out the data stream to write to, not null
|
|
||||||
*/
|
|
||||||
public void writeExternal(ObjectOutput out) throws IOException {
|
|
||||||
writeInternal(type, object, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void writeInternal(byte type, Object object, DataOutput out) throws IOException {
|
|
||||||
out.writeByte(type);
|
|
||||||
switch (type) {
|
|
||||||
case DURATION_TYPE:
|
|
||||||
((Duration) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case INSTANT_TYPE:
|
|
||||||
((Instant) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case LOCAL_DATE_TYPE:
|
|
||||||
((LocalDate) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case LOCAL_DATE_TIME_TYPE:
|
|
||||||
((LocalDateTime) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case LOCAL_TIME_TYPE:
|
|
||||||
((LocalTime) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case MONTH_DAY_TYPE:
|
|
||||||
((MonthDay) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case OFFSET_DATE_TIME_TYPE:
|
|
||||||
((OffsetDateTime) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case OFFSET_TIME_TYPE:
|
|
||||||
((OffsetTime) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case YEAR_MONTH_TYPE:
|
|
||||||
((YearMonth) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case YEAR_TYPE:
|
|
||||||
((Year) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case ZONE_REGION_TYPE:
|
|
||||||
((ZoneRegion) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case ZONE_OFFSET_TYPE:
|
|
||||||
((ZoneOffset) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case ZONED_DATE_TIME_TYPE:
|
|
||||||
((ZonedDateTime) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new InvalidClassException("Unknown serialized type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Implements the {@code Externalizable} interface to read the object.
|
|
||||||
*
|
|
||||||
* @param in the data to read, not null
|
|
||||||
*/
|
|
||||||
public void readExternal(ObjectInput in) throws IOException {
|
|
||||||
type = in.readByte();
|
|
||||||
object = readInternal(type, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Object read(DataInput in) throws IOException {
|
|
||||||
byte type = in.readByte();
|
|
||||||
return readInternal(type, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object readInternal(byte type, DataInput in) throws IOException {
|
|
||||||
switch (type) {
|
|
||||||
case DURATION_TYPE: return Duration.readExternal(in);
|
|
||||||
case INSTANT_TYPE: return Instant.readExternal(in);
|
|
||||||
case LOCAL_DATE_TYPE: return LocalDate.readExternal(in);
|
|
||||||
case LOCAL_DATE_TIME_TYPE: return LocalDateTime.readExternal(in);
|
|
||||||
case LOCAL_TIME_TYPE: return LocalTime.readExternal(in);
|
|
||||||
case MONTH_DAY_TYPE: return MonthDay.readExternal(in);
|
|
||||||
case OFFSET_DATE_TIME_TYPE: return OffsetDateTime.readExternal(in);
|
|
||||||
case OFFSET_TIME_TYPE: return OffsetTime.readExternal(in);
|
|
||||||
case YEAR_TYPE: return Year.readExternal(in);
|
|
||||||
case YEAR_MONTH_TYPE: return YearMonth.readExternal(in);
|
|
||||||
case ZONED_DATE_TIME_TYPE: return ZonedDateTime.readExternal(in);
|
|
||||||
case ZONE_OFFSET_TYPE: return ZoneOffset.readExternal(in);
|
|
||||||
case ZONE_REGION_TYPE: return ZoneRegion.readExternal(in);
|
|
||||||
default:
|
|
||||||
throw new StreamCorruptedException("Unknown serialized type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the object that will replace this one.
|
|
||||||
*
|
|
||||||
* @return the read object, should never be null
|
|
||||||
*/
|
|
||||||
private Object readResolve() {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -40,11 +40,6 @@ import static org.threeten.bp.temporal.ChronoUnit.ERAS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.MILLENNIA;
|
import static org.threeten.bp.temporal.ChronoUnit.MILLENNIA;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.YEARS;
|
import static org.threeten.bp.temporal.ChronoUnit.YEARS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -107,10 +102,6 @@ public final class Year
|
||||||
*/
|
*/
|
||||||
public static final int MAX_VALUE = 999999999;
|
public static final int MAX_VALUE = 999999999;
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -23038383694477807L;
|
|
||||||
/**
|
/**
|
||||||
* Parser.
|
* Parser.
|
||||||
*/
|
*/
|
||||||
|
@ -947,27 +938,4 @@ public final class Year
|
||||||
Objects.requireNonNull(formatter, "formatter");
|
Objects.requireNonNull(formatter, "formatter");
|
||||||
return formatter.format(this);
|
return formatter.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.YEAR_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeInt(year);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Year readExternal(DataInput in) throws IOException {
|
|
||||||
return Year.of(in.readInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,6 @@ import static org.threeten.bp.temporal.ChronoUnit.MILLENNIA;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.MONTHS;
|
import static org.threeten.bp.temporal.ChronoUnit.MONTHS;
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.YEARS;
|
import static org.threeten.bp.temporal.ChronoUnit.YEARS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -94,10 +89,6 @@ import org.threeten.bp.temporal.ValueRange;
|
||||||
public final class YearMonth
|
public final class YearMonth
|
||||||
implements Temporal, TemporalAdjuster, Comparable<YearMonth>, Serializable, TemporalAccessor {
|
implements Temporal, TemporalAdjuster, Comparable<YearMonth>, Serializable, TemporalAccessor {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 4183400860270640070L;
|
|
||||||
/**
|
/**
|
||||||
* Parser.
|
* Parser.
|
||||||
*/
|
*/
|
||||||
|
@ -1068,30 +1059,4 @@ public final class YearMonth
|
||||||
Objects.requireNonNull(formatter, "formatter");
|
Objects.requireNonNull(formatter, "formatter");
|
||||||
return formatter.format(this);
|
return formatter.format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.YEAR_MONTH_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeInt(year);
|
|
||||||
out.writeByte(month);
|
|
||||||
}
|
|
||||||
|
|
||||||
static YearMonth readExternal(DataInput in) throws IOException {
|
|
||||||
int year = in.readInt();
|
|
||||||
byte month = in.readByte();
|
|
||||||
return YearMonth.of(year, month);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp;
|
package org.threeten.bp;
|
||||||
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -223,10 +221,6 @@ public abstract class ZoneId implements Serializable {
|
||||||
base.put("HST", "-10:00");
|
base.put("HST", "-10:00");
|
||||||
SHORT_IDS = Collections.unmodifiableMap(base);
|
SHORT_IDS = Collections.unmodifiableMap(base);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 8352817235686L;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -558,7 +552,4 @@ public abstract class ZoneId implements Serializable {
|
||||||
return getId();
|
return getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
abstract void write(DataOutput out) throws IOException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,6 @@ package org.threeten.bp;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -111,10 +106,6 @@ public final class ZoneOffset
|
||||||
* The abs maximum seconds.
|
* The abs maximum seconds.
|
||||||
*/
|
*/
|
||||||
private static final int MAX_SECONDS = 18 * SECONDS_PER_HOUR;
|
private static final int MAX_SECONDS = 18 * SECONDS_PER_HOUR;
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 2357656521762053153L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time-zone offset for UTC, with an ID of 'Z'.
|
* The time-zone offset for UTC, with an ID of 'Z'.
|
||||||
|
@ -713,39 +704,4 @@ public final class ZoneOffset
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.ZONE_OFFSET_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void write(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(Ser.ZONE_OFFSET_TYPE);
|
|
||||||
writeExternal(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
final int offsetSecs = totalSeconds;
|
|
||||||
int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72
|
|
||||||
out.writeByte(offsetByte);
|
|
||||||
if (offsetByte == 127) {
|
|
||||||
out.writeInt(offsetSecs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ZoneOffset readExternal(DataInput in) throws IOException {
|
|
||||||
int offsetByte = in.readByte();
|
|
||||||
return (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp;
|
package org.threeten.bp;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -64,10 +59,6 @@ import org.threeten.bp.zone.ZoneRulesProvider;
|
||||||
*/
|
*/
|
||||||
final class ZoneRegion extends ZoneId implements Serializable {
|
final class ZoneRegion extends ZoneId implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 8386373296231747096L;
|
|
||||||
/**
|
/**
|
||||||
* The regex pattern for region IDs.
|
* The regex pattern for region IDs.
|
||||||
*/
|
*/
|
||||||
|
@ -176,34 +167,4 @@ final class ZoneRegion extends ZoneId implements Serializable {
|
||||||
// that the provider was added after the ZoneId was created
|
// that the provider was added after the ZoneId was created
|
||||||
return (rules != null ? rules : ZoneRulesProvider.getRules(id, false));
|
return (rules != null ? rules : ZoneRulesProvider.getRules(id, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.ZONE_REGION_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
void write(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(Ser.ZONE_REGION_TYPE);
|
|
||||||
writeExternal(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeUTF(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ZoneId readExternal(DataInput in) throws IOException {
|
|
||||||
String id = in.readUTF();
|
|
||||||
return ofLenient(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,6 @@ import static org.threeten.bp.temporal.ChronoField.INSTANT_SECONDS;
|
||||||
import static org.threeten.bp.temporal.ChronoField.NANO_OF_SECOND;
|
import static org.threeten.bp.temporal.ChronoField.NANO_OF_SECOND;
|
||||||
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
import static org.threeten.bp.temporal.ChronoField.OFFSET_SECONDS;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -2081,31 +2076,5 @@ public final class ZonedDateTime
|
||||||
return super.format(formatter);
|
return super.format(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.ZONED_DATE_TIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
dateTime.writeExternal(out);
|
|
||||||
offset.writeExternal(out);
|
|
||||||
zone.write(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ZonedDateTime readExternal(DataInput in) throws IOException {
|
|
||||||
LocalDateTime dateTime = LocalDateTime.readExternal(in);
|
|
||||||
ZoneOffset offset = ZoneOffset.readExternal(in);
|
|
||||||
ZoneId zone = (ZoneId) Ser.read(in);
|
|
||||||
return ZonedDateTime.ofLenient(dateTime, offset, zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,11 +112,6 @@ abstract class ChronoDateImpl<D extends ChronoLocalDate>
|
||||||
extends ChronoLocalDate
|
extends ChronoLocalDate
|
||||||
implements Temporal, TemporalAdjuster, Serializable {
|
implements Temporal, TemporalAdjuster, Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 6282433883239719096L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance.
|
* Creates an instance.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,9 +33,6 @@ package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.EPOCH_DAY;
|
import static org.threeten.bp.temporal.ChronoField.EPOCH_DAY;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInput;
|
|
||||||
import java.io.ObjectOutput;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -70,10 +67,6 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
|
||||||
extends ChronoLocalDateTime<D>
|
extends ChronoLocalDateTime<D>
|
||||||
implements Temporal, TemporalAdjuster, Serializable {
|
implements Temporal, TemporalAdjuster, Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 4556003607393004514L;
|
|
||||||
/**
|
/**
|
||||||
* Hours per minute.
|
* Hours per minute.
|
||||||
*/
|
*/
|
||||||
|
@ -348,20 +341,4 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
|
||||||
return unit.between(this, end);
|
return unit.between(this, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.CHRONO_LOCALDATETIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(ObjectOutput out) throws IOException {
|
|
||||||
out.writeObject(date);
|
|
||||||
out.writeObject(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChronoLocalDateTime<?> readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
|
||||||
ChronoLocalDate date = (ChronoLocalDate) in.readObject();
|
|
||||||
LocalTime time = (LocalTime) in.readObject();
|
|
||||||
return date.atTime(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,11 +57,6 @@ final class ChronoPeriodImpl
|
||||||
extends ChronoPeriod
|
extends ChronoPeriod
|
||||||
implements Serializable {
|
implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 275618735781L;
|
|
||||||
|
|
||||||
private final Chronology chronology;
|
private final Chronology chronology;
|
||||||
private final int years;
|
private final int years;
|
||||||
private final int months;
|
private final int months;
|
||||||
|
|
|
@ -33,11 +33,6 @@ package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoUnit.SECONDS;
|
import static org.threeten.bp.temporal.ChronoUnit.SECONDS;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectInput;
|
|
||||||
import java.io.ObjectOutput;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -74,11 +69,6 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
||||||
extends ChronoZonedDateTime<D>
|
extends ChronoZonedDateTime<D>
|
||||||
implements Serializable {
|
implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -5261813987200935591L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The local date-time.
|
* The local date-time.
|
||||||
*/
|
*/
|
||||||
|
@ -273,34 +263,6 @@ final class ChronoZonedDateTimeImpl<D extends ChronoLocalDate>
|
||||||
return unit.between(this, end);
|
return unit.between(this, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.CHRONO_ZONEDDATETIME_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(ObjectOutput out) throws IOException {
|
|
||||||
out.writeObject(dateTime);
|
|
||||||
out.writeObject(offset);
|
|
||||||
out.writeObject(zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChronoZonedDateTime<?> readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
|
||||||
ChronoLocalDateTime<?> dateTime = (ChronoLocalDateTime<?>) in.readObject();
|
|
||||||
ZoneOffset offset = (ZoneOffset) in.readObject();
|
|
||||||
ZoneId zone = (ZoneId) in.readObject();
|
|
||||||
return dateTime.atZone(offset).withZoneSameLocal(zone);
|
|
||||||
// TODO: ZDT uses ofLenient()
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp.chrono;
|
package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -835,27 +830,4 @@ public abstract class Chronology implements Comparable<Chronology> {
|
||||||
return getId();
|
return getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.CHRONO_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Defend against malicious streams.
|
|
||||||
* @return never
|
|
||||||
* @throws InvalidObjectException always
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
throw new InvalidObjectException("Deserialization via serialization delegate");
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeUTF(getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
static Chronology readExternal(DataInput in) throws IOException {
|
|
||||||
String id = in.readUTF();
|
|
||||||
return Chronology.of(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,10 +176,6 @@ public final class HijrahChronology extends Chronology implements Serializable {
|
||||||
*/
|
*/
|
||||||
public static final HijrahChronology INSTANCE = new HijrahChronology();
|
public static final HijrahChronology INSTANCE = new HijrahChronology();
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 3127340209035924785L;
|
|
||||||
/**
|
/**
|
||||||
* Narrow names for eras.
|
* Narrow names for eras.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,13 +35,8 @@ import static org.threeten.bp.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH;
|
||||||
import static org.threeten.bp.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR;
|
import static org.threeten.bp.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR;
|
||||||
import static org.threeten.bp.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH;
|
import static org.threeten.bp.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH;
|
||||||
import static org.threeten.bp.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR;
|
import static org.threeten.bp.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR;
|
||||||
import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH;
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -115,11 +110,6 @@ public final class HijrahDate
|
||||||
// this class is package-scoped so that future conversion to public
|
// this class is package-scoped so that future conversion to public
|
||||||
// would not change serialization
|
// would not change serialization
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -5207853542612002020L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum valid year-of-era.
|
* The minimum valid year-of-era.
|
||||||
*/
|
*/
|
||||||
|
@ -604,15 +594,6 @@ public final class HijrahDate
|
||||||
this.isLeapYear = isLeapYear(this.yearOfEra);
|
this.isLeapYear = isLeapYear(this.yearOfEra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces the date instance from the stream with a valid one.
|
|
||||||
*
|
|
||||||
* @return the resolved date, never null
|
|
||||||
*/
|
|
||||||
private Object readResolve() {
|
|
||||||
return new HijrahDate(this.gregorianEpochDay);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public HijrahChronology getChronology() {
|
public HijrahChronology getChronology() {
|
||||||
|
@ -1756,23 +1737,4 @@ public final class HijrahDate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.HIJRAH_DATE_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
// HijrahChrono is implicit in the Hijrah_DATE_TYPE
|
|
||||||
out.writeInt(get(YEAR));
|
|
||||||
out.writeByte(get(MONTH_OF_YEAR));
|
|
||||||
out.writeByte(get(DAY_OF_MONTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChronoLocalDate readExternal(DataInput in) throws IOException {
|
|
||||||
int year = in.readInt();
|
|
||||||
int month = in.readByte();
|
|
||||||
int dayOfMonth = in.readByte();
|
|
||||||
return HijrahChronology.INSTANCE.date(year, month, dayOfMonth);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.ERA;
|
import static org.threeten.bp.temporal.ChronoField.ERA;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.threeten.bp.DateTimeException;
|
import org.threeten.bp.DateTimeException;
|
||||||
|
@ -183,18 +180,4 @@ public enum HijrahEra implements Era {
|
||||||
return (this == HijrahEra.AH ? yearOfEra : 1 - yearOfEra);
|
return (this == HijrahEra.AH ? yearOfEra : 1 - yearOfEra);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.HIJRAH_ERA_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(this.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
static HijrahEra readExternal(DataInput in) throws IOException {
|
|
||||||
byte eraValue = in.readByte();
|
|
||||||
return HijrahEra.of(eraValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,11 +103,6 @@ public final class IsoChronology extends Chronology implements Serializable {
|
||||||
*/
|
*/
|
||||||
public static final IsoChronology INSTANCE = new IsoChronology();
|
public static final IsoChronology INSTANCE = new IsoChronology();
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -1440403870442975015L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restricted constructor.
|
* Restricted constructor.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -109,11 +109,6 @@ public final class JapaneseChronology extends Chronology implements Serializable
|
||||||
*/
|
*/
|
||||||
public static final JapaneseChronology INSTANCE = new JapaneseChronology();
|
public static final JapaneseChronology INSTANCE = new JapaneseChronology();
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 459996390165777884L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Narrow names for eras.
|
* Narrow names for eras.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,14 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp.chrono;
|
package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH;
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -85,10 +77,6 @@ public final class JapaneseDate
|
||||||
extends ChronoDateImpl<JapaneseDate>
|
extends ChronoDateImpl<JapaneseDate>
|
||||||
implements Serializable {
|
implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -305327627230580483L;
|
|
||||||
/**
|
/**
|
||||||
* Minimum date.
|
* Minimum date.
|
||||||
*/
|
*/
|
||||||
|
@ -306,18 +294,6 @@ public final class JapaneseDate
|
||||||
this.isoDate = isoDate;
|
this.isoDate = isoDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public JapaneseChronology getChronology() {
|
public JapaneseChronology getChronology() {
|
||||||
|
@ -583,25 +559,4 @@ public final class JapaneseDate
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getChronology().getId().hashCode() ^ isoDate.hashCode();
|
return getChronology().getId().hashCode() ^ isoDate.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.JAPANESE_DATE_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
// JapaneseChrono is implicit in the JAPANESE_DATE_TYPE
|
|
||||||
out.writeInt(get(YEAR));
|
|
||||||
out.writeByte(get(MONTH_OF_YEAR));
|
|
||||||
out.writeByte(get(DAY_OF_MONTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChronoLocalDate readExternal(DataInput in) throws IOException {
|
|
||||||
int year = in.readInt();
|
|
||||||
int month = in.readByte();
|
|
||||||
int dayOfMonth = in.readByte();
|
|
||||||
return JapaneseChronology.INSTANCE.date(year, month, dayOfMonth);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp.chrono;
|
package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -97,11 +92,6 @@ public final class JapaneseEra
|
||||||
*/
|
*/
|
||||||
private static final int ADDITIONAL_VALUE = 4;
|
private static final int ADDITIONAL_VALUE = 4;
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1466499369062886794L;
|
|
||||||
|
|
||||||
// array for the singleton JapaneseEra instances
|
// array for the singleton JapaneseEra instances
|
||||||
private static JapaneseEra[] KNOWN_ERAS;
|
private static JapaneseEra[] KNOWN_ERAS;
|
||||||
|
|
||||||
|
@ -139,24 +129,6 @@ public final class JapaneseEra
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the singleton {@code JapaneseEra} corresponding to this object.
|
|
||||||
* It's possible that this version of {@code JapaneseEra} doesn't support the latest era value.
|
|
||||||
* In that case, this method throws an {@code ObjectStreamException}.
|
|
||||||
*
|
|
||||||
* @return the singleton {@code JapaneseEra} for this object
|
|
||||||
* @throws ObjectStreamException if the deserialized object has any unknown numeric era value.
|
|
||||||
*/
|
|
||||||
private Object readResolve() throws ObjectStreamException {
|
|
||||||
try {
|
|
||||||
return of(eraValue);
|
|
||||||
} catch (DateTimeException e) {
|
|
||||||
InvalidObjectException ex = new InvalidObjectException("Invalid era");
|
|
||||||
ex.initCause(e);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Registers an additional instance of {@code JapaneseEra}.
|
* Registers an additional instance of {@code JapaneseEra}.
|
||||||
|
@ -326,19 +298,4 @@ public final class JapaneseEra
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.JAPANESE_ERA_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(this.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
static JapaneseEra readExternal(DataInput in) throws IOException {
|
|
||||||
byte eraValue = in.readByte();
|
|
||||||
return JapaneseEra.of(eraValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,10 +102,6 @@ public final class MinguoChronology extends Chronology implements Serializable {
|
||||||
*/
|
*/
|
||||||
public static final MinguoChronology INSTANCE = new MinguoChronology();
|
public static final MinguoChronology INSTANCE = new MinguoChronology();
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1039765215346859963L;
|
|
||||||
/**
|
/**
|
||||||
* The difference in years between ISO and Minguo.
|
* The difference in years between ISO and Minguo.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,13 +32,8 @@
|
||||||
package org.threeten.bp.chrono;
|
package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.chrono.MinguoChronology.YEARS_DIFFERENCE;
|
import static org.threeten.bp.chrono.MinguoChronology.YEARS_DIFFERENCE;
|
||||||
import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH;
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -72,11 +67,6 @@ public final class MinguoDate
|
||||||
extends ChronoDateImpl<MinguoDate>
|
extends ChronoDateImpl<MinguoDate>
|
||||||
implements Serializable {
|
implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1300372329181994526L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The underlying date.
|
* The underlying date.
|
||||||
*/
|
*/
|
||||||
|
@ -356,26 +346,4 @@ public final class MinguoDate
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getChronology().getId().hashCode() ^ isoDate.hashCode();
|
return getChronology().getId().hashCode() ^ isoDate.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.MINGUO_DATE_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
// MinguoChrono is implicit in the MINGUO_DATE_TYPE
|
|
||||||
out.writeInt(get(YEAR));
|
|
||||||
out.writeByte(get(MONTH_OF_YEAR));
|
|
||||||
out.writeByte(get(DAY_OF_MONTH));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChronoLocalDate readExternal(DataInput in) throws IOException {
|
|
||||||
int year = in.readInt();
|
|
||||||
int month = in.readByte();
|
|
||||||
int dayOfMonth = in.readByte();
|
|
||||||
return MinguoChronology.INSTANCE.date(year, month, dayOfMonth);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.ERA;
|
import static org.threeten.bp.temporal.ChronoField.ERA;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.threeten.bp.DateTimeException;
|
import org.threeten.bp.DateTimeException;
|
||||||
|
@ -172,19 +169,4 @@ public enum MinguoEra implements Era {
|
||||||
public String getDisplayName(TextStyle style, Locale locale) {
|
public String getDisplayName(TextStyle style, Locale locale) {
|
||||||
return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this);
|
return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.MINGUO_ERA_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(this.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
static MinguoEra readExternal(DataInput in) throws IOException {
|
|
||||||
byte eraValue = in.readByte();
|
|
||||||
return MinguoEra.of(eraValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,203 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* * Neither the name of JSR-310 nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package org.threeten.bp.chrono;
|
|
||||||
|
|
||||||
import java.io.Externalizable;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidClassException;
|
|
||||||
import java.io.ObjectInput;
|
|
||||||
import java.io.ObjectOutput;
|
|
||||||
import java.io.StreamCorruptedException;
|
|
||||||
|
|
||||||
import org.threeten.bp.LocalDate;
|
|
||||||
import org.threeten.bp.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shared serialization delegate for this package.
|
|
||||||
*
|
|
||||||
* <h4>Implementation notes</h4>
|
|
||||||
* This class wraps the object being serialized, and takes a byte representing the type of the class to
|
|
||||||
* be serialized. This byte can also be used for versioning the serialization format. In this case another
|
|
||||||
* byte flag would be used in order to specify an alternative version of the type format.
|
|
||||||
* For example {@code JAPANESE_DATE_TYPE_VERSION_2 = 21}.
|
|
||||||
* <p>
|
|
||||||
* In order to serialise the object it writes its byte and then calls back to the appropriate class where
|
|
||||||
* the serialisation is performed. In order to deserialise the object it read in the type byte, switching
|
|
||||||
* in order to select which class to call back into.
|
|
||||||
* <p>
|
|
||||||
* The serialisation format is determined on a per class basis. In the case of field based classes each
|
|
||||||
* of the fields is written out with an appropriate size format in descending order of the field's size. For
|
|
||||||
* example in the case of {@link LocalDate} year is written before month. Composite classes, such as
|
|
||||||
* {@link LocalDateTime} are serialised as one object.
|
|
||||||
* <p>
|
|
||||||
* This class is mutable and should be created once per serialization.
|
|
||||||
*
|
|
||||||
* @serial include
|
|
||||||
*/
|
|
||||||
final class Ser implements Externalizable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 7857518227608961174L;
|
|
||||||
|
|
||||||
static final byte JAPANESE_DATE_TYPE = 1;
|
|
||||||
static final byte JAPANESE_ERA_TYPE = 2;
|
|
||||||
static final byte HIJRAH_DATE_TYPE = 3;
|
|
||||||
static final byte HIJRAH_ERA_TYPE = 4;
|
|
||||||
static final byte MINGUO_DATE_TYPE = 5;
|
|
||||||
static final byte MINGUO_ERA_TYPE = 6;
|
|
||||||
static final byte THAIBUDDHIST_DATE_TYPE = 7;
|
|
||||||
static final byte THAIBUDDHIST_ERA_TYPE = 8;
|
|
||||||
static final byte CHRONO_TYPE = 11;
|
|
||||||
static final byte CHRONO_LOCALDATETIME_TYPE = 12;
|
|
||||||
static final byte CHRONO_ZONEDDATETIME_TYPE = 13;
|
|
||||||
|
|
||||||
/** The type being serialized. */
|
|
||||||
private byte type;
|
|
||||||
/** The object being serialized. */
|
|
||||||
private Object object;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for deserialization.
|
|
||||||
*/
|
|
||||||
public Ser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an instance for serialization.
|
|
||||||
*
|
|
||||||
* @param type the type
|
|
||||||
* @param object the object
|
|
||||||
*/
|
|
||||||
Ser(byte type, Object object) {
|
|
||||||
this.type = type;
|
|
||||||
this.object = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Implements the {@code Externalizable} interface to write the object.
|
|
||||||
*
|
|
||||||
* @param out the data stream to write to, not null
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void writeExternal(ObjectOutput out) throws IOException {
|
|
||||||
writeInternal(type, object, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void writeInternal(byte type, Object object, ObjectOutput out) throws IOException {
|
|
||||||
out.writeByte(type);
|
|
||||||
switch (type) {
|
|
||||||
case JAPANESE_DATE_TYPE:
|
|
||||||
((JapaneseDate) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case JAPANESE_ERA_TYPE:
|
|
||||||
((JapaneseEra) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case HIJRAH_DATE_TYPE:
|
|
||||||
((HijrahDate) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case HIJRAH_ERA_TYPE:
|
|
||||||
((HijrahEra) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case MINGUO_DATE_TYPE:
|
|
||||||
((MinguoDate) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case MINGUO_ERA_TYPE:
|
|
||||||
((MinguoEra) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case THAIBUDDHIST_DATE_TYPE:
|
|
||||||
((ThaiBuddhistDate) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case THAIBUDDHIST_ERA_TYPE:
|
|
||||||
((ThaiBuddhistEra) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case CHRONO_TYPE:
|
|
||||||
((Chronology) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case CHRONO_LOCALDATETIME_TYPE:
|
|
||||||
((ChronoLocalDateTimeImpl<?>) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case CHRONO_ZONEDDATETIME_TYPE:
|
|
||||||
((ChronoZonedDateTimeImpl<?>) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new InvalidClassException("Unknown serialized type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Implements the {@code Externalizable} interface to read the object.
|
|
||||||
*
|
|
||||||
* @param in the data to read, not null
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
|
||||||
type = in.readByte();
|
|
||||||
object = readInternal(type, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Object read(ObjectInput in) throws IOException, ClassNotFoundException {
|
|
||||||
byte type = in.readByte();
|
|
||||||
return readInternal(type, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object readInternal(byte type, ObjectInput in) throws IOException, ClassNotFoundException {
|
|
||||||
switch (type) {
|
|
||||||
case JAPANESE_DATE_TYPE: return JapaneseDate.readExternal(in);
|
|
||||||
case JAPANESE_ERA_TYPE: return JapaneseEra.readExternal(in);
|
|
||||||
case HIJRAH_DATE_TYPE: return HijrahDate.readExternal(in);
|
|
||||||
case HIJRAH_ERA_TYPE: return HijrahEra.readExternal(in);
|
|
||||||
case MINGUO_DATE_TYPE: return MinguoDate.readExternal(in);
|
|
||||||
case MINGUO_ERA_TYPE: return MinguoEra.readExternal(in);
|
|
||||||
case THAIBUDDHIST_DATE_TYPE: return ThaiBuddhistDate.readExternal(in);
|
|
||||||
case THAIBUDDHIST_ERA_TYPE: return ThaiBuddhistEra.readExternal(in);
|
|
||||||
case CHRONO_TYPE: return Chronology.readExternal(in);
|
|
||||||
case CHRONO_LOCALDATETIME_TYPE: return ChronoLocalDateTimeImpl.readExternal(in);
|
|
||||||
case CHRONO_ZONEDDATETIME_TYPE: return ChronoZonedDateTimeImpl.readExternal(in);
|
|
||||||
default:
|
|
||||||
throw new StreamCorruptedException("Unknown serialized type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the object that will replace this one.
|
|
||||||
*
|
|
||||||
* @return the read object, should never be null
|
|
||||||
*/
|
|
||||||
private Object readResolve() {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -103,10 +103,6 @@ public final class ThaiBuddhistChronology extends Chronology implements Serializ
|
||||||
*/
|
*/
|
||||||
public static final ThaiBuddhistChronology INSTANCE = new ThaiBuddhistChronology();
|
public static final ThaiBuddhistChronology INSTANCE = new ThaiBuddhistChronology();
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 2775954514031616474L;
|
|
||||||
/**
|
/**
|
||||||
* Containing the offset to add to the ISO year.
|
* Containing the offset to add to the ISO year.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,9 +36,6 @@ import static org.threeten.bp.temporal.ChronoField.DAY_OF_MONTH;
|
||||||
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
import static org.threeten.bp.temporal.ChronoField.MONTH_OF_YEAR;
|
||||||
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
import static org.threeten.bp.temporal.ChronoField.YEAR;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -72,11 +69,6 @@ public final class ThaiBuddhistDate
|
||||||
extends ChronoDateImpl<ThaiBuddhistDate>
|
extends ChronoDateImpl<ThaiBuddhistDate>
|
||||||
implements Serializable {
|
implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -8722293800195731463L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The underlying date.
|
* The underlying date.
|
||||||
*/
|
*/
|
||||||
|
@ -356,24 +348,4 @@ public final class ThaiBuddhistDate
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getChronology().getId().hashCode() ^ isoDate.hashCode();
|
return getChronology().getId().hashCode() ^ isoDate.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.THAIBUDDHIST_DATE_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
// MinguoChrono is implicit in the THAIBUDDHIST_DATE_TYPE
|
|
||||||
out.writeInt(this.get(YEAR));
|
|
||||||
out.writeByte(this.get(MONTH_OF_YEAR));
|
|
||||||
out.writeByte(this.get(DAY_OF_MONTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChronoLocalDate readExternal(DataInput in) throws IOException {
|
|
||||||
int year = in.readInt();
|
|
||||||
int month = in.readByte();
|
|
||||||
int dayOfMonth = in.readByte();
|
|
||||||
return ThaiBuddhistChronology.INSTANCE.date(year, month, dayOfMonth);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,6 @@ package org.threeten.bp.chrono;
|
||||||
|
|
||||||
import static org.threeten.bp.temporal.ChronoField.ERA;
|
import static org.threeten.bp.temporal.ChronoField.ERA;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.threeten.bp.DateTimeException;
|
import org.threeten.bp.DateTimeException;
|
||||||
|
@ -171,19 +168,4 @@ public enum ThaiBuddhistEra implements Era {
|
||||||
public String getDisplayName(TextStyle style, Locale locale) {
|
public String getDisplayName(TextStyle style, Locale locale) {
|
||||||
return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this);
|
return new DateTimeFormatterBuilder().appendText(ERA, style).toFormatter(locale).format(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.THAIBUDDHIST_ERA_TYPE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeByte(this.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
static ThaiBuddhistEra readExternal(DataInput in) throws IOException {
|
|
||||||
byte eraValue = in.readByte();
|
|
||||||
return ThaiBuddhistEra.of(eraValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,6 @@ import org.threeten.bp.DateTimeException;
|
||||||
*/
|
*/
|
||||||
public class DateTimeParseException extends DateTimeException {
|
public class DateTimeParseException extends DateTimeException {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 4304633501674722597L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The text that was being parsed.
|
* The text that was being parsed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,11 +41,6 @@ import org.threeten.bp.DateTimeException;
|
||||||
*/
|
*/
|
||||||
public class UnsupportedTemporalTypeException extends DateTimeException {
|
public class UnsupportedTemporalTypeException extends DateTimeException {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -189676278478L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new date-time exception with the specified message.
|
* Constructs a new date-time exception with the specified message.
|
||||||
*
|
*
|
||||||
|
|
|
@ -55,11 +55,6 @@ import org.threeten.bp.DateTimeException;
|
||||||
*/
|
*/
|
||||||
public final class ValueRange implements Serializable {
|
public final class ValueRange implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -7317881728594519368L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The smallest minimum value.
|
* The smallest minimum value.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -151,11 +151,6 @@ public final class WeekFields implements Serializable {
|
||||||
*/
|
*/
|
||||||
public static final WeekFields SUNDAY_START = WeekFields.of(DayOfWeek.SUNDAY, 1);
|
public static final WeekFields SUNDAY_START = WeekFields.of(DayOfWeek.SUNDAY, 1);
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -1177360819670808121L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The first day-of-week.
|
* The first day-of-week.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,226 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* * Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* * Neither the name of JSR-310 nor the names of its contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package org.threeten.bp.zone;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.Externalizable;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InvalidClassException;
|
|
||||||
import java.io.ObjectInput;
|
|
||||||
import java.io.ObjectOutput;
|
|
||||||
import java.io.StreamCorruptedException;
|
|
||||||
|
|
||||||
import org.threeten.bp.ZoneOffset;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The shared serialization delegate for this package.
|
|
||||||
*
|
|
||||||
* <h4>Implementation notes</h4>
|
|
||||||
* This class is mutable and should be created once per serialization.
|
|
||||||
*
|
|
||||||
* @serial include
|
|
||||||
*/
|
|
||||||
final class Ser implements Externalizable {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -8885321777449118786L;
|
|
||||||
|
|
||||||
/** Type for StandardZoneRules. */
|
|
||||||
static final byte SZR = 1;
|
|
||||||
/** Type for ZoneOffsetTransition. */
|
|
||||||
static final byte ZOT = 2;
|
|
||||||
/** Type for ZoneOffsetTransition. */
|
|
||||||
static final byte ZOTRULE = 3;
|
|
||||||
|
|
||||||
/** The type being serialized. */
|
|
||||||
private byte type;
|
|
||||||
/** The object being serialized. */
|
|
||||||
private Object object;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for deserialization.
|
|
||||||
*/
|
|
||||||
public Ser() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an instance for serialization.
|
|
||||||
*
|
|
||||||
* @param type the type
|
|
||||||
* @param object the object
|
|
||||||
*/
|
|
||||||
Ser(byte type, Object object) {
|
|
||||||
this.type = type;
|
|
||||||
this.object = object;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Implements the {@code Externalizable} interface to write the object.
|
|
||||||
*
|
|
||||||
* @param out the data stream to write to, not null
|
|
||||||
*/
|
|
||||||
public void writeExternal(ObjectOutput out) throws IOException {
|
|
||||||
writeInternal(type, object, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write(Object object, DataOutput out) throws IOException {
|
|
||||||
writeInternal(SZR, object, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void writeInternal(byte type, Object object, DataOutput out) throws IOException {
|
|
||||||
out.writeByte(type);
|
|
||||||
switch (type) {
|
|
||||||
case SZR:
|
|
||||||
((StandardZoneRules) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case ZOT:
|
|
||||||
((ZoneOffsetTransition) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
case ZOTRULE:
|
|
||||||
((ZoneOffsetTransitionRule) object).writeExternal(out);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new InvalidClassException("Unknown serialized type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Implements the {@code Externalizable} interface to read the object.
|
|
||||||
*
|
|
||||||
* @param in the data to read, not null
|
|
||||||
*/
|
|
||||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
|
||||||
type = in.readByte();
|
|
||||||
object = readInternal(type, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Object read(DataInput in) throws IOException, ClassNotFoundException {
|
|
||||||
byte type = in.readByte();
|
|
||||||
return readInternal(type, in);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Object readInternal(byte type, DataInput in) throws IOException, ClassNotFoundException {
|
|
||||||
switch (type) {
|
|
||||||
case SZR:
|
|
||||||
return StandardZoneRules.readExternal(in);
|
|
||||||
case ZOT:
|
|
||||||
return ZoneOffsetTransition.readExternal(in);
|
|
||||||
case ZOTRULE:
|
|
||||||
return ZoneOffsetTransitionRule.readExternal(in);
|
|
||||||
default:
|
|
||||||
throw new StreamCorruptedException("Unknown serialized type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the object that will replace this one.
|
|
||||||
*
|
|
||||||
* @return the read object, should never be null
|
|
||||||
*/
|
|
||||||
private Object readResolve() {
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Writes the state to the stream.
|
|
||||||
*
|
|
||||||
* @param offset the offset, not null
|
|
||||||
* @param out the output stream, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static void writeOffset(ZoneOffset offset, DataOutput out) throws IOException {
|
|
||||||
final int offsetSecs = offset.getTotalSeconds();
|
|
||||||
int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127; // compress to -72 to +72
|
|
||||||
out.writeByte(offsetByte);
|
|
||||||
if (offsetByte == 127) {
|
|
||||||
out.writeInt(offsetSecs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the state from the stream.
|
|
||||||
*
|
|
||||||
* @param in the input stream, not null
|
|
||||||
* @return the created object, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static ZoneOffset readOffset(DataInput in) throws IOException {
|
|
||||||
int offsetByte = in.readByte();
|
|
||||||
return (offsetByte == 127 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(offsetByte * 900));
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Writes the state to the stream.
|
|
||||||
*
|
|
||||||
* @param epochSec the epoch seconds, not null
|
|
||||||
* @param out the output stream, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static void writeEpochSec(long epochSec, DataOutput out) throws IOException {
|
|
||||||
if (epochSec >= -4575744000L && epochSec < 10413792000L && epochSec % 900 == 0) { // quarter hours between 1825 and 2300
|
|
||||||
int store = (int) ((epochSec + 4575744000L) / 900);
|
|
||||||
out.writeByte((store >>> 16) & 255);
|
|
||||||
out.writeByte((store >>> 8) & 255);
|
|
||||||
out.writeByte(store & 255);
|
|
||||||
} else {
|
|
||||||
out.writeByte(255);
|
|
||||||
out.writeLong(epochSec);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the state from the stream.
|
|
||||||
*
|
|
||||||
* @param in the input stream, not null
|
|
||||||
* @return the epoch seconds, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static long readEpochSec(DataInput in) throws IOException {
|
|
||||||
int hiByte = in.readByte() & 255;
|
|
||||||
if (hiByte == 255) {
|
|
||||||
return in.readLong();
|
|
||||||
} else {
|
|
||||||
int midByte = in.readByte() & 255;
|
|
||||||
int loByte = in.readByte() & 255;
|
|
||||||
long tot = ((hiByte << 16) + (midByte << 8) + loByte);
|
|
||||||
return (tot * 900) - 4575744000L;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -31,9 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp.zone;
|
package org.threeten.bp.zone;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -59,11 +56,6 @@ import org.threeten.bp.jdk8.Jdk8Methods;
|
||||||
* This class is immutable and thread-safe.
|
* This class is immutable and thread-safe.
|
||||||
*/
|
*/
|
||||||
final class StandardZoneRules extends ZoneRules implements Serializable {
|
final class StandardZoneRules extends ZoneRules implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 3044319355680032515L;
|
|
||||||
/**
|
/**
|
||||||
* The last year to have its transitions cached.
|
* The last year to have its transitions cached.
|
||||||
*/
|
*/
|
||||||
|
@ -196,77 +188,6 @@ final class StandardZoneRules extends ZoneRules implements Serializable {
|
||||||
this.savingsLocalTransitions = localTransitionList.toArray(new LocalDateTime[localTransitionList.size()]);
|
this.savingsLocalTransitions = localTransitionList.toArray(new LocalDateTime[localTransitionList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Uses a serialization delegate.
|
|
||||||
*
|
|
||||||
* @return the replacing object, not null
|
|
||||||
*/
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.SZR, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the state to the stream.
|
|
||||||
*
|
|
||||||
* @param out the output stream, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
out.writeInt(standardTransitions.length);
|
|
||||||
for (long trans : standardTransitions) {
|
|
||||||
Ser.writeEpochSec(trans, out);
|
|
||||||
}
|
|
||||||
for (ZoneOffset offset : standardOffsets) {
|
|
||||||
Ser.writeOffset(offset, out);
|
|
||||||
}
|
|
||||||
out.writeInt(savingsInstantTransitions.length);
|
|
||||||
for (long trans : savingsInstantTransitions) {
|
|
||||||
Ser.writeEpochSec(trans, out);
|
|
||||||
}
|
|
||||||
for (ZoneOffset offset : wallOffsets) {
|
|
||||||
Ser.writeOffset(offset, out);
|
|
||||||
}
|
|
||||||
out.writeByte(lastRules.length);
|
|
||||||
for (ZoneOffsetTransitionRule rule : lastRules) {
|
|
||||||
rule.writeExternal(out);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the state from the stream.
|
|
||||||
*
|
|
||||||
* @param in the input stream, not null
|
|
||||||
* @return the created object, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static StandardZoneRules readExternal(DataInput in) throws IOException, ClassNotFoundException {
|
|
||||||
int stdSize = in.readInt();
|
|
||||||
long[] stdTrans = new long[stdSize];
|
|
||||||
for (int i = 0; i < stdSize; i++) {
|
|
||||||
stdTrans[i] = Ser.readEpochSec(in);
|
|
||||||
}
|
|
||||||
ZoneOffset[] stdOffsets = new ZoneOffset[stdSize + 1];
|
|
||||||
for (int i = 0; i < stdOffsets.length; i++) {
|
|
||||||
stdOffsets[i] = Ser.readOffset(in);
|
|
||||||
}
|
|
||||||
int savSize = in.readInt();
|
|
||||||
long[] savTrans = new long[savSize];
|
|
||||||
for (int i = 0; i < savSize; i++) {
|
|
||||||
savTrans[i] = Ser.readEpochSec(in);
|
|
||||||
}
|
|
||||||
ZoneOffset[] savOffsets = new ZoneOffset[savSize + 1];
|
|
||||||
for (int i = 0; i < savOffsets.length; i++) {
|
|
||||||
savOffsets[i] = Ser.readOffset(in);
|
|
||||||
}
|
|
||||||
int ruleSize = in.readByte();
|
|
||||||
ZoneOffsetTransitionRule[] rules = new ZoneOffsetTransitionRule[ruleSize];
|
|
||||||
for (int i = 0; i < ruleSize; i++) {
|
|
||||||
rules[i] = ZoneOffsetTransitionRule.readExternal(in);
|
|
||||||
}
|
|
||||||
return new StandardZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@Override
|
@Override
|
||||||
public boolean isFixedOffset() {
|
public boolean isFixedOffset() {
|
||||||
|
|
|
@ -414,7 +414,7 @@ final class TzdbZoneRulesCompiler {
|
||||||
for (ZoneRules rules : rulesList) {
|
for (ZoneRules rules : rulesList) {
|
||||||
baos.reset();
|
baos.reset();
|
||||||
DataOutputStream dataos = new DataOutputStream(baos);
|
DataOutputStream dataos = new DataOutputStream(baos);
|
||||||
Ser.write(rules, dataos);
|
//Ser.write(rules, dataos);
|
||||||
dataos.close();
|
dataos.close();
|
||||||
byte[] bytes = baos.toByteArray();
|
byte[] bytes = baos.toByteArray();
|
||||||
out.writeShort(bytes.length);
|
out.writeShort(bytes.length);
|
||||||
|
|
|
@ -50,8 +50,6 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||||
|
|
||||||
import org.threeten.bp.jdk8.Jdk8Methods;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads time-zone rules for 'TZDB'.
|
* Loads time-zone rules for 'TZDB'.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -316,7 +314,7 @@ public final class TzdbZoneRulesProvider extends ZoneRulesProvider {
|
||||||
if (obj instanceof byte[]) {
|
if (obj instanceof byte[]) {
|
||||||
byte[] bytes = (byte[]) obj;
|
byte[] bytes = (byte[]) obj;
|
||||||
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes));
|
DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes));
|
||||||
obj = Ser.read(dis);
|
obj = null; //Ser.read(dis);
|
||||||
ruleData.set(index, obj);
|
ruleData.set(index, obj);
|
||||||
}
|
}
|
||||||
return (ZoneRules) obj;
|
return (ZoneRules) obj;
|
||||||
|
|
|
@ -31,9 +31,6 @@
|
||||||
*/
|
*/
|
||||||
package org.threeten.bp.zone;
|
package org.threeten.bp.zone;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -66,10 +63,6 @@ import org.threeten.bp.ZoneOffset;
|
||||||
public final class ZoneOffsetTransition
|
public final class ZoneOffsetTransition
|
||||||
implements Comparable<ZoneOffsetTransition>, Serializable {
|
implements Comparable<ZoneOffsetTransition>, Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -6946044323557704546L;
|
|
||||||
/**
|
/**
|
||||||
* The local transition date-time at the transition.
|
* The local transition date-time at the transition.
|
||||||
*/
|
*/
|
||||||
|
@ -137,45 +130,6 @@ public final class ZoneOffsetTransition
|
||||||
this.offsetAfter = offsetAfter;
|
this.offsetAfter = offsetAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Uses a serialization delegate.
|
|
||||||
*
|
|
||||||
* @return the replacing object, not null
|
|
||||||
*/
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.ZOT, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the state to the stream.
|
|
||||||
*
|
|
||||||
* @param out the output stream, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
Ser.writeEpochSec(toEpochSecond(), out);
|
|
||||||
Ser.writeOffset(offsetBefore, out);
|
|
||||||
Ser.writeOffset(offsetAfter, out);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the state from the stream.
|
|
||||||
*
|
|
||||||
* @param in the input stream, not null
|
|
||||||
* @return the created object, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static ZoneOffsetTransition readExternal(DataInput in) throws IOException {
|
|
||||||
long epochSecond = Ser.readEpochSec(in);
|
|
||||||
ZoneOffset before = Ser.readOffset(in);
|
|
||||||
ZoneOffset after = Ser.readOffset(in);
|
|
||||||
if (before.equals(after)) {
|
|
||||||
throw new IllegalArgumentException("Offsets must not be equal");
|
|
||||||
}
|
|
||||||
return new ZoneOffsetTransition(epochSecond, before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the transition instant.
|
* Gets the transition instant.
|
||||||
|
|
|
@ -34,9 +34,6 @@ package org.threeten.bp.zone;
|
||||||
import static org.threeten.bp.temporal.TemporalAdjusters.nextOrSame;
|
import static org.threeten.bp.temporal.TemporalAdjusters.nextOrSame;
|
||||||
import static org.threeten.bp.temporal.TemporalAdjusters.previousOrSame;
|
import static org.threeten.bp.temporal.TemporalAdjusters.previousOrSame;
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataOutput;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -67,10 +64,6 @@ import org.threeten.bp.jdk8.Jdk8Methods;
|
||||||
*/
|
*/
|
||||||
public final class ZoneOffsetTransitionRule implements Serializable {
|
public final class ZoneOffsetTransitionRule implements Serializable {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 6889046316657758795L;
|
|
||||||
/**
|
/**
|
||||||
* The number of seconds per day.
|
* The number of seconds per day.
|
||||||
*/
|
*/
|
||||||
|
@ -203,87 +196,6 @@ public final class ZoneOffsetTransitionRule implements Serializable {
|
||||||
this.offsetAfter = offsetAfter;
|
this.offsetAfter = offsetAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Uses a serialization delegate.
|
|
||||||
*
|
|
||||||
* @return the replacing object, not null
|
|
||||||
*/
|
|
||||||
private Object writeReplace() {
|
|
||||||
return new Ser(Ser.ZOTRULE, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the state to the stream.
|
|
||||||
*
|
|
||||||
* @param out the output stream, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
void writeExternal(DataOutput out) throws IOException {
|
|
||||||
final int timeSecs = time.toSecondOfDay() + adjustDays * SECS_PER_DAY;
|
|
||||||
final int stdOffset = standardOffset.getTotalSeconds();
|
|
||||||
final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
|
|
||||||
final int afterDiff = offsetAfter.getTotalSeconds() - stdOffset;
|
|
||||||
final int timeByte = (timeSecs % 3600 == 0 && timeSecs <= SECS_PER_DAY ?
|
|
||||||
(timeSecs == SECS_PER_DAY ? 24 : time.getHour()) : 31);
|
|
||||||
final int stdOffsetByte = (stdOffset % 900 == 0 ? stdOffset / 900 + 128 : 255);
|
|
||||||
final int beforeByte = (beforeDiff == 0 || beforeDiff == 1800 || beforeDiff == 3600 ? beforeDiff / 1800 : 3);
|
|
||||||
final int afterByte = (afterDiff == 0 || afterDiff == 1800 || afterDiff == 3600 ? afterDiff / 1800 : 3);
|
|
||||||
final int dowByte = (dow == null ? 0 : dow.getValue());
|
|
||||||
int b = (month.getValue() << 28) + // 4 bits
|
|
||||||
((dom + 32) << 22) + // 6 bits
|
|
||||||
(dowByte << 19) + // 3 bits
|
|
||||||
(timeByte << 14) + // 5 bits
|
|
||||||
(timeDefinition.ordinal() << 12) + // 2 bits
|
|
||||||
(stdOffsetByte << 4) + // 8 bits
|
|
||||||
(beforeByte << 2) + // 2 bits
|
|
||||||
afterByte; // 2 bits
|
|
||||||
out.writeInt(b);
|
|
||||||
if (timeByte == 31) {
|
|
||||||
out.writeInt(timeSecs);
|
|
||||||
}
|
|
||||||
if (stdOffsetByte == 255) {
|
|
||||||
out.writeInt(stdOffset);
|
|
||||||
}
|
|
||||||
if (beforeByte == 3) {
|
|
||||||
out.writeInt(offsetBefore.getTotalSeconds());
|
|
||||||
}
|
|
||||||
if (afterByte == 3) {
|
|
||||||
out.writeInt(offsetAfter.getTotalSeconds());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads the state from the stream.
|
|
||||||
*
|
|
||||||
* @param in the input stream, not null
|
|
||||||
* @return the created object, not null
|
|
||||||
* @throws IOException if an error occurs
|
|
||||||
*/
|
|
||||||
static ZoneOffsetTransitionRule readExternal(DataInput in) throws IOException {
|
|
||||||
int data = in.readInt();
|
|
||||||
Month month = Month.of(data >>> 28);
|
|
||||||
int dom = ((data & (63 << 22)) >>> 22) - 32;
|
|
||||||
int dowByte = (data & (7 << 19)) >>> 19;
|
|
||||||
DayOfWeek dow = dowByte == 0 ? null : DayOfWeek.of(dowByte);
|
|
||||||
int timeByte = (data & (31 << 14)) >>> 14;
|
|
||||||
TimeDefinition defn = TimeDefinition.values()[(data & (3 << 12)) >>> 12];
|
|
||||||
int stdByte = (data & (255 << 4)) >>> 4;
|
|
||||||
int beforeByte = (data & (3 << 2)) >>> 2;
|
|
||||||
int afterByte = (data & 3);
|
|
||||||
int timeOfDaysSecs = (timeByte == 31 ? in.readInt() : timeByte * 3600);
|
|
||||||
ZoneOffset std = (stdByte == 255 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds((stdByte - 128) * 900));
|
|
||||||
ZoneOffset before = (beforeByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + beforeByte * 1800));
|
|
||||||
ZoneOffset after = (afterByte == 3 ? ZoneOffset.ofTotalSeconds(in.readInt()) : ZoneOffset.ofTotalSeconds(std.getTotalSeconds() + afterByte * 1800));
|
|
||||||
// only bit of validation that we need to copy from public of() method
|
|
||||||
if (dom < -28 || dom > 31 || dom == 0) {
|
|
||||||
throw new IllegalArgumentException("Day of month indicator must be between -28 and 31 inclusive excluding zero");
|
|
||||||
}
|
|
||||||
LocalTime time = LocalTime.ofSecondOfDay(Jdk8Methods.floorMod(timeOfDaysSecs, SECS_PER_DAY));
|
|
||||||
int adjustDays = Jdk8Methods.floorDiv(timeOfDaysSecs, SECS_PER_DAY);
|
|
||||||
return new ZoneOffsetTransitionRule(month, dom, dow, time, adjustDays, defn, std, before, after);
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Gets the month of the transition.
|
* Gets the month of the transition.
|
||||||
|
|
|
@ -400,8 +400,6 @@ public abstract class ZoneRules {
|
||||||
* Fixed time-zone.
|
* Fixed time-zone.
|
||||||
*/
|
*/
|
||||||
static final class Fixed extends ZoneRules implements Serializable {
|
static final class Fixed extends ZoneRules implements Serializable {
|
||||||
/** A serialization identifier for this class. */
|
|
||||||
private static final long serialVersionUID = -8733721350312276297L;
|
|
||||||
/** The offset. */
|
/** The offset. */
|
||||||
private final ZoneOffset offset;
|
private final ZoneOffset offset;
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,6 @@ import org.threeten.bp.DateTimeException;
|
||||||
*/
|
*/
|
||||||
public class ZoneRulesException extends DateTimeException {
|
public class ZoneRulesException extends DateTimeException {
|
||||||
|
|
||||||
/**
|
|
||||||
* Serialization version.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = -1632418723876261839L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new date-time exception with the specified message.
|
* Constructs a new date-time exception with the specified message.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user