Serialized Form

  • Package org.bardframework.time

  • Package org.bardframework.time.zone

    • Class org.bardframework.time.zone.ZoneOffsetTransition

      class ZoneOffsetTransition extends Object implements Serializable
      serialVersionUID:
      -6946044323557704546L
      • Serialization Methods

      • Serialized Fields

        • epochSecond
          long epochSecond
          The transition epoch-second.
        • offsetAfter
          ZoneOffset offsetAfter
          The offset after transition.
        • offsetBefore
          ZoneOffset offsetBefore
          The offset before transition.
        • transition
          LocalDateTimeJalali transition
          The local transition date-time at the transition.
    • Class org.bardframework.time.zone.ZoneOffsetTransitionRule

      class ZoneOffsetTransitionRule extends Object implements Serializable
      serialVersionUID:
      6889046316657758795L
      • Serialization Methods

        • readObject
          private void readObject(ObjectInputStream s) throws InvalidObjectException
          Defend against malicious streams.
          Parameters:
          s - the stream to read
          Throws:
          InvalidObjectException - always
        • writeReplace
          private Object writeReplace()
          Writes the object using a dedicated serialized form.
          Serial Data:
          Refer to the serialized form of ZoneRules.writeReplace for the encoding of epoch seconds and offsets.
          
          
                out.writeByte(3);                // identifies a ZoneOffsetTransitionRule
                final int timeSecs = (timeEndOfDay ? 86400 : time.toSecondOfDay());
                final int stdOffset = standardOffset.getTotalSeconds();
                final int beforeDiff = offsetBefore.getTotalSeconds() - stdOffset;
                final int afterDiff = offsetAfter.getTotalSeconds() - stdOffset;
                final int timeByte = (timeSecs % 3600 == 0 ? (timeEndOfDay ? 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());
                }
           
           
      • Serialized Fields

        • dom
          byte dom
          The day-of-month of the month-day of the cutover week. If positive, it is the start of the week where the cutover can occur. If negative, it represents the end of the week where cutover can occur. The value is the number of days from the end of the month, such that -1 is the last day of the month, -2 is the second to last day, and so on.
        • dow
          DayOfWeek dow
          The cutover day-of-week, null to retain the day-of-month.
        • month
          MonthJalali month
          The month of the month-day of the first day of the cutover week. The actual date will be adjusted by the dowChange field.
        • offsetAfter
          ZoneOffset offsetAfter
          The offset after the cutover.
        • offsetBefore
          ZoneOffset offsetBefore
          The offset before the cutover.
        • standardOffset
          ZoneOffset standardOffset
          The standard offset at the cutover.
        • time
          LocalTime time
          The cutover time in the 'before' offset.
        • timeDefinition
          ZoneOffsetTransitionRule.TimeDefinition timeDefinition
          The definition of how the local time should be interpreted.
        • timeEndOfDay
          boolean timeEndOfDay
          Whether the cutover time is midnight at the end of day.
    • Class org.bardframework.time.zone.ZoneRules

      class ZoneRules extends Object implements Serializable
      serialVersionUID:
      3044319355680032515L
      • Serialization Methods

        • readObject
          private void readObject(ObjectInputStream s) throws InvalidObjectException
          Defend against malicious streams.
          Parameters:
          s - the stream to read
          Throws:
          InvalidObjectException - always
        • writeReplace
          private Object writeReplace()
          Writes the object using a dedicated serialized form.
          Serial Data:
          
          
             out.writeByte(1);  // identifies a ZoneRules
             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);
             }
           
           

          Epoch second values used for offsets are encoded in a variable length form to make the common cases put fewer bytes in the stream.

          
          
            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);
                }
            }
           
           

          ZoneOffset values are encoded in a variable length form so the common cases put fewer bytes in the stream.

          
          
            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);
               }
           }
           
           
      • Serialized Fields

        • lastRules
          ZoneOffsetTransitionRule[] lastRules
          The last rule.
        • savingsInstantTransitions
          long[] savingsInstantTransitions
          The transitions between instants (epoch seconds), sorted.
        • savingsLocalTransitions
          LocalDateTimeJalali[] savingsLocalTransitions
          The transitions between local date-times, sorted. This is a paired array, where the first entry is the start of the transition and the second entry is the end of the transition.
        • standardOffsets
          ZoneOffset[] standardOffsets
          The standard offsets.
        • standardTransitions
          long[] standardTransitions
          The transitions between standard offsets (epoch seconds), sorted.
        • wallOffsets
          ZoneOffset[] wallOffsets
          The wall offsets.