/// <summary> /// Reads the state from the stream. /// </summary> /// <param name="in"> the input stream, not null </param> /// <returns> the created object, not null </returns> /// <exception cref="IOException"> if an error occurs </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: static ZoneOffsetTransition readExternal(java.io.DataInput in) throws java.io.IOException internal static ZoneOffsetTransition ReadExternal(DataInput @in) { 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)); }
//----------------------------------------------------------------------- /// <summary> /// Checks if this object equals another. /// <para> /// The entire state of the object is compared. /// /// </para> /// </summary> /// <param name="other"> the other object to compare to, null returns false </param> /// <returns> true if equal </returns> public override bool Equals(Object other) { if (other == this) { return(true); } if (other is ZoneOffsetTransition) { ZoneOffsetTransition d = (ZoneOffsetTransition)other; return(Transition.Equals(d.Transition) && OffsetBefore_Renamed.Equals(d.OffsetBefore_Renamed) && OffsetAfter_Renamed.Equals(d.OffsetAfter_Renamed)); } return(false); }
public override ChronoZonedDateTime<D> WithLaterOffsetAtOverlap() { ZoneOffsetTransition trans = Zone.Rules.GetTransition(LocalDateTime.From(this)); if (trans != null) { ZoneOffset offset = trans.OffsetAfter; if (offset.Equals(Offset) == false) { return new ChronoZonedDateTimeImpl<>(DateTime, offset, Zone_Renamed); } } return this; }
public override ChronoZonedDateTime<D> WithEarlierOffsetAtOverlap() { ZoneOffsetTransition trans = Zone.Rules.GetTransition(LocalDateTime.From(this)); if (trans != null && trans.Overlap) { ZoneOffset earlierOffset = trans.OffsetBefore; if (earlierOffset.Equals(Offset_Renamed) == false) { return new ChronoZonedDateTimeImpl<>(DateTime, earlierOffset, Zone_Renamed); } } return this; }
//----------------------------------------------------------------------- /// <summary> /// Obtains an instance defining a transition between two offsets. /// <para> /// Applications should normally obtain an instance from <seealso cref="ZoneRules"/>. /// This factory is only intended for use when creating <seealso cref="ZoneRules"/>. /// /// </para> /// </summary> /// <param name="transition"> the transition date-time at the transition, which never /// actually occurs, expressed local to the before offset, not null </param> /// <param name="offsetBefore"> the offset before the transition, not null </param> /// <param name="offsetAfter"> the offset at and after the transition, not null </param> /// <returns> the transition, not null </returns> /// <exception cref="IllegalArgumentException"> if {@code offsetBefore} and {@code offsetAfter} /// are equal, or {@code transition.getNano()} returns non-zero value </exception> public static ZoneOffsetTransition Of(LocalDateTime transition, ZoneOffset offsetBefore, ZoneOffset offsetAfter) { Objects.RequireNonNull(transition, "transition"); Objects.RequireNonNull(offsetBefore, "offsetBefore"); Objects.RequireNonNull(offsetAfter, "offsetAfter"); if (offsetBefore.Equals(offsetAfter)) { throw new IllegalArgumentException("Offsets must not be equal"); } if (transition.Nano != 0) { throw new IllegalArgumentException("Nano-of-second must be zero"); } return(new ZoneOffsetTransition(transition, offsetBefore, offsetAfter)); }
private static string CurrentTimeZoneOffsetString() { ZoneOffset offset = OffsetDateTime.now().Offset; return(offset.Equals(UTC) ? "+0000" : offset.ToString().Replace(":", "")); }