/** * 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 ZoneRules readExternal(DataInput in) throws IOException, ClassNotFoundException { int stdSize = in.readInt(); long[] stdTrans = (stdSize == 0) ? EMPTY_LONG_ARRAY : 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 = (savSize == 0) ? EMPTY_LONG_ARRAY : 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 = (ruleSize == 0) ? EMPTY_LASTRULES : new ZoneOffsetTransitionRule[ruleSize]; for (int i = 0; i < ruleSize; i++) { rules[i] = ZoneOffsetTransitionRule.readExternal(in); } return new ZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules); }
/** * 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); }
/** * 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); return ZoneOffsetTransition.of(OffsetDateTime.ofEpochSecond(epochSecond, before), after); }