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);
}
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 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);
}
int hyear
int hmonth
int hdom
java.lang.String variant
java.lang.String name
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()
1. 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 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.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.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
ZonalOffset offset
private void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
private void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private java.lang.Object writeReplace()
private void readObject(java.io.ObjectInputStream in)
throws java.io.InvalidObjectException
java.io.InvalidObjectException - (always)private 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 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 bit-compressed representation.
writeReplace()-method of object
to be serializedjava.io.IOException - in any case of IO-failures