Java Code Examples for java.time.ZoneOffset#equals()

The following examples show how to use java.time.ZoneOffset#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZoneOffsetTransition.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: ZoneOffsetTransition.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: ZoneOffsetTransition.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: ChronoZonedDateTimeImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null) {
        ZoneOffset offset = trans.getOffsetAfter();
        if (offset.equals(getOffset()) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, offset, zone);
        }
    }
    return this;
}
 
Example 5
Source File: ChronoZonedDateTimeImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null && trans.isOverlap()) {
        ZoneOffset earlierOffset = trans.getOffsetBefore();
        if (earlierOffset.equals(offset) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, earlierOffset, zone);
        }
    }
    return this;
}
 
Example 6
Source File: ChronoZonedDateTimeImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null) {
        ZoneOffset offset = trans.getOffsetAfter();
        if (offset.equals(getOffset()) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, offset, zone);
        }
    }
    return this;
}
 
Example 7
Source File: ChronoZonedDateTimeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null) {
        ZoneOffset offset = trans.getOffsetAfter();
        if (offset.equals(getOffset()) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, offset, zone);
        }
    }
    return this;
}
 
Example 8
Source File: ChronoZonedDateTimeImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null) {
        ZoneOffset offset = trans.getOffsetAfter();
        if (offset.equals(getOffset()) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, offset, zone);
        }
    }
    return this;
}
 
Example 9
Source File: ZoneOffsetTransition.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 10
Source File: ChronoZonedDateTimeImpl.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null) {
        ZoneOffset offset = trans.getOffsetAfter();
        if (offset.equals(getOffset()) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, offset, zone);
        }
    }
    return this;
}
 
Example 11
Source File: ChronoZonedDateTimeImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null && trans.isOverlap()) {
        ZoneOffset earlierOffset = trans.getOffsetBefore();
        if (earlierOffset.equals(offset) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, earlierOffset, zone);
        }
    }
    return this;
}
 
Example 12
Source File: ZoneOffsetTransition.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 13
Source File: ChronoZonedDateTimeImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withLaterOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null) {
        ZoneOffset offset = trans.getOffsetAfter();
        if (offset.equals(getOffset()) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, offset, zone);
        }
    }
    return this;
}
 
Example 14
Source File: ZoneOffsetTransition.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: ChronoZonedDateTimeImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ChronoZonedDateTime<D> withEarlierOffsetAtOverlap() {
    ZoneOffsetTransition trans = getZone().getRules().getTransition(LocalDateTime.from(this));
    if (trans != null && trans.isOverlap()) {
        ZoneOffset earlierOffset = trans.getOffsetBefore();
        if (earlierOffset.equals(offset) == false) {
            return new ChronoZonedDateTimeImpl<>(dateTime, earlierOffset, zone);
        }
    }
    return this;
}
 
Example 16
Source File: ZoneOffsetTransition.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Obtains an instance defining a transition between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param transition  the transition date-time at the transition, which never
 *  actually occurs, expressed local to the before offset, not null
 * @param offsetBefore  the offset before the transition, not null
 * @param offsetAfter  the offset at and after the transition, not null
 * @return the transition, not null
 * @throws IllegalArgumentException if {@code offsetBefore} and {@code offsetAfter}
 *         are equal, or {@code transition.getNano()} returns non-zero value
 */
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.getNano() != 0) {
        throw new IllegalArgumentException("Nano-of-second must be zero");
    }
    return new ZoneOffsetTransition(transition, offsetBefore, offsetAfter);
}
 
Example 17
Source File: ZoneOffsetTransition.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Obtains an instance defining a transition between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param transition  the transition date-time at the transition, which never
 *  actually occurs, expressed local to the before offset, not null
 * @param offsetBefore  the offset before the transition, not null
 * @param offsetAfter  the offset at and after the transition, not null
 * @return the transition, not null
 * @throws IllegalArgumentException if {@code offsetBefore} and {@code offsetAfter}
 *         are equal, or {@code transition.getNano()} returns non-zero value
 */
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.getNano() != 0) {
        throw new IllegalArgumentException("Nano-of-second must be zero");
    }
    return new ZoneOffsetTransition(transition, offsetBefore, offsetAfter);
}
 
Example 18
Source File: ZoneOffsetTransition.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Obtains an instance defining a transition between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param transition  the transition date-time at the transition, which never
 *  actually occurs, expressed local to the before offset, not null
 * @param offsetBefore  the offset before the transition, not null
 * @param offsetAfter  the offset at and after the transition, not null
 * @return the transition, not null
 * @throws IllegalArgumentException if {@code offsetBefore} and {@code offsetAfter}
 *         are equal, or {@code transition.getNano()} returns non-zero value
 */
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.getNano() != 0) {
        throw new IllegalArgumentException("Nano-of-second must be zero");
    }
    return new ZoneOffsetTransition(transition, offsetBefore, offsetAfter);
}
 
Example 19
Source File: ZoneOffsetTransition.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Obtains an instance defining a transition between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param transition  the transition date-time at the transition, which never
 *  actually occurs, expressed local to the before offset, not null
 * @param offsetBefore  the offset before the transition, not null
 * @param offsetAfter  the offset at and after the transition, not null
 * @return the transition, not null
 * @throws IllegalArgumentException if {@code offsetBefore} and {@code offsetAfter}
 *         are equal, or {@code transition.getNano()} returns non-zero value
 */
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.getNano() != 0) {
        throw new IllegalArgumentException("Nano-of-second must be zero");
    }
    return new ZoneOffsetTransition(transition, offsetBefore, offsetAfter);
}
 
Example 20
Source File: ZoneOffsetTransition.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Obtains an instance defining a transition between two offsets.
 * <p>
 * Applications should normally obtain an instance from {@link ZoneRules}.
 * This factory is only intended for use when creating {@link ZoneRules}.
 *
 * @param transition  the transition date-time at the transition, which never
 *  actually occurs, expressed local to the before offset, not null
 * @param offsetBefore  the offset before the transition, not null
 * @param offsetAfter  the offset at and after the transition, not null
 * @return the transition, not null
 * @throws IllegalArgumentException if {@code offsetBefore} and {@code offsetAfter}
 *         are equal, or {@code transition.getNano()} returns non-zero value
 */
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.getNano() != 0) {
        throw new IllegalArgumentException("Nano-of-second must be zero");
    }
    return new ZoneOffsetTransition(transition, offsetBefore, offsetAfter);
}