public static ZoneRules readZoneRules(DataInputStream stream) throws IOException, ClassNotFoundException { return StandardZoneRules.readExternal(stream); }
public static void writeZoneRules(ZoneRules rules, DataOutputStream stream) throws IOException { ((StandardZoneRules) rules).writeExternal(stream); } }
@Override public boolean isDaylightSavings(Instant instant) { return (getStandardOffset(instant).equals(getOffset(instant)) == false); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Fixed) { return offset.equals(((Fixed) obj).offset); } if (obj instanceof StandardZoneRules) { StandardZoneRules szr = (StandardZoneRules) obj; return szr.isFixedOffset() && offset.equals(szr.getOffset(Instant.EPOCH)); } return false; }
int year = findYear(epochSec, wallOffsets[wallOffsets.length - 1]); ZoneOffsetTransition[] transArray = findTransitionArray(year); for (ZoneOffsetTransition trans : transArray) { if (epochSec < trans.toEpochSecond()) { transArray = findTransitionArray(year + 1); return transArray[0];
ZoneOffsetTransition[] transArray = findTransitionArray(dt.getYear()); Object info = null; for (ZoneOffsetTransition trans : transArray) { info = findOffsetInfo(dt, trans); if (info instanceof ZoneOffsetTransition || info.equals(trans.getOffsetBefore())) { return info;
@Override public ZoneOffsetTransition getTransition(LocalDateTime localDateTime) { Object info = getOffsetInfo(localDateTime); return (info instanceof ZoneOffsetTransition ? (ZoneOffsetTransition) info : null); }
rules[i] = ZoneOffsetTransitionRule.readExternal(in); return new StandardZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules);
int year = findYear(epochSec, wallOffsets[wallOffsets.length - 1]); ZoneOffsetTransition[] transArray = findTransitionArray(year); for (ZoneOffsetTransition trans : transArray) { if (epochSec < trans.toEpochSecond()) { transArray = findTransitionArray(year + 1); return transArray[0];
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof Fixed) { return offset.equals(((Fixed) obj).offset); } if (obj instanceof StandardZoneRules) { StandardZoneRules szr = (StandardZoneRules) obj; return szr.isFixedOffset() && offset.equals(szr.getOffset(Instant.EPOCH)); } return false; }
ZoneOffsetTransition[] transArray = findTransitionArray(dt.getYear()); Object info = null; for (ZoneOffsetTransition trans : transArray) { info = findOffsetInfo(dt, trans); if (info instanceof ZoneOffsetTransition || info.equals(trans.getOffsetBefore())) { return info;
@Override public ZoneOffsetTransition getTransition(LocalDateTime localDateTime) { Object info = getOffsetInfo(localDateTime); return (info instanceof ZoneOffsetTransition ? (ZoneOffsetTransition) info : null); }
rules[i] = ZoneOffsetTransitionRule.readExternal(in); return new StandardZoneRules(stdTrans, stdOffsets, savTrans, savOffsets, rules);
public static ZoneRules readZoneRules(DataInput input) throws Exception { return StandardZoneRules.readExternal(input); } }
int year = findYear(epochSec, lastHistoricOffset); ZoneOffsetTransition[] transArray = findTransitionArray(year); for (int i = transArray.length - 1; i >= 0; i--) { if (epochSec > transArray[i].toEpochSecond()) { int lastHistoricYear = findYear(lastHistoric, lastHistoricOffset); if (--year > lastHistoricYear) { transArray = findTransitionArray(year); return transArray[transArray.length - 1];
@Override public boolean isDaylightSavings(Instant instant) { return (getStandardOffset(instant).equals(getOffset(instant)) == false); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof StandardZoneRules) { StandardZoneRules other = (StandardZoneRules) obj; return Arrays.equals(standardTransitions, other.standardTransitions) && Arrays.equals(standardOffsets, other.standardOffsets) && Arrays.equals(savingsInstantTransitions, other.savingsInstantTransitions) && Arrays.equals(wallOffsets, other.wallOffsets) && Arrays.equals(lastRules, other.lastRules); } if (obj instanceof Fixed) { return isFixedOffset() && getOffset(Instant.EPOCH).equals(((Fixed) obj).getOffset(Instant.EPOCH)); } return false; }
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"); } }
@Override public ZoneOffset getOffset(LocalDateTime localDateTime) { Object info = getOffsetInfo(localDateTime); if (info instanceof ZoneOffsetTransition) { return ((ZoneOffsetTransition) info).getOffsetBefore(); } return (ZoneOffset) info; }
/** * Obtains an instance of {@code ZoneRules} with full transition rules. * * @param baseStandardOffset the standard offset to use before legal rules were set, not null * @param baseWallOffset the wall offset to use before legal rules were set, not null * @param standardOffsetTransitionList the list of changes to the standard offset, not null * @param transitionList the list of transitions, not null * @param lastRules the recurring last rules, size 16 or less, not null * @return the zone rules, not null */ public static ZoneRules of(ZoneOffset baseStandardOffset, ZoneOffset baseWallOffset, List<ZoneOffsetTransition> standardOffsetTransitionList, List<ZoneOffsetTransition> transitionList, List<ZoneOffsetTransitionRule> lastRules) { Jdk8Methods.requireNonNull(baseStandardOffset, "baseStandardOffset"); Jdk8Methods.requireNonNull(baseWallOffset, "baseWallOffset"); Jdk8Methods.requireNonNull(standardOffsetTransitionList, "standardOffsetTransitionList"); Jdk8Methods.requireNonNull(transitionList, "transitionList"); Jdk8Methods.requireNonNull(lastRules, "lastRules"); return new StandardZoneRules(baseStandardOffset, baseWallOffset, standardOffsetTransitionList, transitionList, lastRules); }