本文整理汇总了Java中java.time.ZoneOffset.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneOffset.equals方法的具体用法?Java ZoneOffset.equals怎么用?Java ZoneOffset.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZoneOffset
的用法示例。
在下文中一共展示了ZoneOffset.equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withEarlierOffsetAtOverlap
import java.time.ZoneOffset; //导入方法依赖的package包/类
@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;
}
示例2: withLaterOffsetAtOverlap
import java.time.ZoneOffset; //导入方法依赖的package包/类
@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;
}
示例3: readExternal
import java.time.ZoneOffset; //导入方法依赖的package包/类
/**
* 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);
}
示例4: of
import java.time.ZoneOffset; //导入方法依赖的package包/类
/**
* 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);
}