long days
PlainTime time
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
6 and as
least significant bit the value 1 if long should be used
for transferring the item amounts (else using int). Then
the data bytes for the duration items follow. The byte
sequence optionally ends with the sign information.
Schematic algorithm:
boolean useLong = ...;
byte header = (6 << 4);
if (useLong) header |= 1;
out.writeByte(header);
out.writeInt(getTotalLength().size());
for (Item<U> item : getTotalLength()) {
if (useLong) {
out.writeLong(item.getAmount());
} else {
out.writeInt((int) item.getAmount());
}
out.writeObject(item.getUnit());
}
if (getTotalLength().size() > 0) {
out.writeBoolean(isNegative());
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
4. The lowest bit is 1 if this
instance is a positive leap second. The bit (2) will be
set if there is a non-zero nanosecond part. After this
header byte eight bytes follow containing the unix time
(as long) and optional four bytes with the fraction part.
Schematic algorithm:
int header = 4;
header <<= 4;
if (isLeapSecond()) {
header |= 1;
}
int fraction = getNanosecond();
if (fraction > 0) {
header |= 2;
}
out.writeByte(header);
out.writeLong(getPosixTime());
if (fraction > 0) {
out.writeInt(fraction);
}
Timezone tz
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
1. The following
bits 4-7 contain the month. The second byte contains
at the bits 1-2 a year mark: 1 = year in the range
1850-2100, 2 = four-digit-year, 3 = year number with more
than four digits. The five least significant bits of second
byte contain the day of month. Then the year will be written
dependent on the year mark. Is the mark 1 then the year
will be written as byte, if the mark is 2 then the year
will be written as short else as int with four bytes.
Schematic algorithm:
int range;
if (year >= 1850 && year <= 2100) {
range = 1;
} else if (Math.abs(year) < 10000) {
range = 2;
} else {
range = 3;
}
int header = 1;
header <<= 4;
header |= month;
out.writeByte(header);
int header2 = range;
header2 <<= 5;
header2 |= dayOfMonth;
out.writeByte(header2);
if (range == 1) {
out.writeByte(year - 1850 - 128);
} else if (range == 2) {
out.writeShort(year);
} else {
out.writeInt(year);
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
2. Then
the data bytes for hour, minute, second and nanosecond
follow (in last case int instead of byte). Is the precision
limited to seconds, minutes or hours then the last non-zero
byte will be bit-inverted by the operator (~), and the
following bytes will be left out. The hour byte however
is always written.
Schematic algorithm:
out.writeByte(2 << 4);
if (time.nano == 0) {
if (time.second == 0) {
if (time.minute == 0) {
out.writeByte(~time.hour);
} else {
out.writeByte(time.hour);
out.writeByte(~time.minute);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(~time.second);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(time.second);
out.writeInt(time.nano);
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
8. Then
the data bytes for date and time component follow.
Schematic algorithm:
int range;
if (year >= 1850 && year <= 2100) {
range = 1;
} else if (Math.abs(year) < 10000) {
range = 2;
} else {
range = 3;
}
int header = 8; // type-id
header <<= 4;
header |= month;
out.writeByte(header);
int header2 = range;
header2 <<= 5;
header2 |= dayOfMonth;
out.writeByte(header2);
if (range == 1) {
out.writeByte(year - 1850 - 128);
} else if (range == 2) {
out.writeShort(year);
} else {
out.writeInt(year);
}
if (time.nano == 0) {
if (time.second == 0) {
if (time.minute == 0) {
out.writeByte(~time.hour);
} else {
out.writeByte(time.hour);
out.writeByte(~time.minute);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(~time.second);
}
} else {
out.writeByte(time.hour);
out.writeByte(time.minute);
out.writeByte(time.second);
out.writeInt(time.nano);
}
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Implementation method of interface Externalizable.
java.io.IOException - in any case of IO-failuresjava.lang.ClassNotFoundException - if class-loading failspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Implementation method of interface Externalizable.
The first byte contains within the 4 most-significant bits the type of the object to be serialized. Then the data bytes follow in a bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in any case of IO-failuresprivate java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamExceptionprivate void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
3. If the weekend
is not saturday and sunday then the four least significant
bits will be set to 1. The second byte has in the
four most significant bits the first day of week, in the
other four bits the minimum days of first calendar week.
If there is no standard weekend then a third byte follows
which contains in the four most significant bits the start
and the four least significant bits the end of weekend.
Schematic algorithm:
boolean isoWeekend = (
(getStartOfWeekend() == Weekday.SATURDAY)
&& (getEndOfWeekend() == Weekday.SUNDAY)
);
int header = 3;
header <<= 4;
if (!isoWeekend) {
header |= 1;
}
out.writeByte(header);
int state = getFirstDayOfWeek().getValue();
state <<= 4;
state |= getMinimalDaysInFirstWeek();
out.writeByte(state);
if (!isoWeekend) {
state = getStartOfWeekend().getValue();
state <<= 4;
state |= getEndOfWeekend().getValue();
out.writeByte(state);
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
3. Then the year is written as int, finally
month and day-of-month as bytes.private java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamException - if deserializing is not possibleint index
boolean leap
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
4. Then the era ordinal is written as byte, the year-of-era
is written as int, finally month and day-of-month written as bytes.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
5. Then the time of day in seconds using western
format is written as integer.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
12. Then the year is written as int, finally
month.getValue() and day-of-month as bytes.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
13. Then a boolean flag is written (set to true if day).
Finally the hour is written as byte and the part of hour written as short integer.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
1. Then the UTF-coded variant and its data version
follow. Finally the year is written as int, month and day-of-month as bytes.
The successful serialization requires equal versions per variant on both sides.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
11. Then the calendar history is written out as UTF-string.
Finally the UTC-epoch-days of corresponding gregorian date will be serialized as long.PlainDate gregorian
ChronoHistory history
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
10. Then the year is written as int, finally
month and day-of-month as bytes.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
9. Then the related gregorian year and the day-of-year
are written as int-primitives. Note that the serialization round-trip
might fail for calendar objects created in lax mode due to normalization.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
7. Then the year is written as int, finally
month and day-of-month as bytes.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
6. Then the associated gregorian date is written.PlainDate iso
private java.lang.Object readResolve()
throws java.io.ObjectStreamException
java.io.ObjectStreamException - if deserializing is not possiblebyte court
int index
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
2. Then the year is written as int, finally
month and day-of-month as bytes.public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Implementation method of interface Externalizable.
java.io.IOException - in any case of IO-failuresjava.lang.ClassNotFoundException - if class loading failspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Implementation method of interface Externalizable.
The first byte contains the type of the object to be serialized. Then the data bytes follow in a possibly bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in any case of IO-failuresprivate void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
8. Then the associated gregorian date is written.PlainDate iso
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.StreamCorruptedException - if the data are not consistentjava.io.IOException - if the data cannot be readdouble value
TimeScale scale
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.IOException - in any case of I/O-errorsjava.lang.IllegalArgumentException - in any case of inconsistent statedouble latitude
double longitude
int altitude
TZID observerZoneID
double rightAscension
double declination
double azimuth
double elevation
double distance
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.IOException - in any case of I/O-errorsjava.lang.IllegalArgumentException - in any case of inconsistent statedouble latitude
double longitude
int altitude
java.lang.String calculator
TZID observerZoneID
double rightAscension
double declination
double azimuth
double elevation
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
11. Then the year is written as int, finally
month and day-of-month as bytes.public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Implementation method of interface Externalizable.
java.io.IOException - in any case of IO-failuresjava.lang.ClassNotFoundException - if class loading failspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Implementation method of interface Externalizable.
The first byte contains the type of the object to be serialized. Then the data bytes follow in a possibly bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in any case of IO-failuresjava.lang.String name
int identity
int hash
long days
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.InvalidObjectException - if the state is inconsistentjava.lang.ClassNotFoundException - if class loading failsjava.io.IOExceptionjava.lang.Object unit
long amount
> 0private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
3.
The following bits 4-7 contain the variant of history. The variant is usually
zero, but for PROLEPTIC_GREGORIAN 1, for PROLEPTIC_JULIAN 2, for PROLEPTIC_BYZANTINE 3,
for SWEDEN 4 and for the first gregorian reform 7. If the variant is zero then the
cutover date in question will be written as long (modified julian date) into the
stream. Then the sequence of eventually set ancient julian leap years will be
written as int-array (length followed by list of extended years). Then the specific
new-year-strategy will be written as count of list of rule-until-pairs followed by
the list entries. Finally the era preference will be written such that non-default
preferences require the byte 127 and else any other number. If non-default then
the preferred era and the start date and the end date will be written.public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Implementation method of interface Externalizable.
java.io.IOException - in any case of IO-failuresjava.lang.ClassNotFoundException - if class loading failspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Implementation method of interface Externalizable.
The first byte contains within the 4 most-significant bits the type of the object to be serialized. Then the data bytes follow in a bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in any case of IO-failuresprivate void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
12. Then the
data bits for the id and the fallback timezone follow.
Schematic algorithm:
int header = (12 << 4); out.writeByte(header); out.writeObject(getID()); out.writeObject(getFallback());
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
14. If there is
a non-default transition strategy then the lowest bit is
set to 1 else to 0. After that the data bits
for the id, history and optionally the special strategy
follow.
Schematic algorithm:
boolean specialStrategy =
(getStrategy() != Timezone.DEFAULT_CONFLICT_STRATEGY);
int header = (14 << 4);
if (specialStrategy) {
header |= 1;
}
out.writeByte(header);
out.writeObject(tz.getID());
out.writeObject(tz.getHistory());
if (specialStrategy) {
out.writeObject(tz.getStrategy());
}
private java.lang.Object readResolve()
TZID id
java.util.TimeZone tz
boolean strict
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.InvalidObjectException - in case of inconsistenciesjava.lang.ClassNotFoundException - if class loading failsjava.io.IOExceptionZonalOffset offset
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Implementation method of interface Externalizable.
java.io.IOException - in any case of IO-failuresjava.lang.ClassNotFoundException - if class loading failspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Implementation method of interface Externalizable.
The first byte contains within the 4 most-significant bits the type of the object to be serialized. Then the data bytes follow in a bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in any case of IO-failuresprivate void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
13. The lower
4 bits contain the concrete value of this strategy.
Schematic algorithm:
int key =
getGapResolver().ordinal() * 2 + getOverlapResolver().ordinal();
int header = (13 << 4);
header |= key;
out.writeByte(header);
private void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
15. If there is
any fractional part then the four least significant bits
are 1 else 0. After that the data bits
for the integral total shift and optionally the fractional
part follow.
Schematic algorithm:
boolean hasFraction = (this.getFractionalAmount() != 0);
int header = (15 << 4);
if (hasFraction) {
header |= 1;
}
out.writeByte(header);
out.writeInt(this.getIntegralAmount());
if (hasFraction) {
out.writeInt(this.getFractionalAmount());
}
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException - in any case of inconsistenciesjava.lang.ClassNotFoundException - if class-loading failslong posix
int previous
int total
int dst
private void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
126. Then the data bytes for the internal
transitions follow. The complex algorithm exploits the
fact that allmost all transitions happen at full hours
around midnight in local standard time. Insight in details
see source code.private void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
127. Then the data bytes for the internal
transitions and rules follow. The complex algorithm
exploits the fact that allmost all transitions happen
at full hours around midnight in local standard time.
Insight in details see source code.private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
ZonalOffset offset
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException
java.io.InvalidObjectException - (always)java.io.IOExceptionprivate java.lang.Object writeReplace()
125. Then the data bytes for the internal
rules follow. The complex algorithm exploits the fact
that allmost all transitions happen at full hours around
midnight. Insight in details see source code.public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Implementation method of interface Externalizable.
java.io.IOException - in case of I/O-problemsjava.lang.ClassNotFoundException - if class-loading failspublic void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Implementation method of interface Externalizable.
The first byte contains the type of the object to be serialized. Then the data bytes follow in a bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in case of I/O-problems