org.threeten.bp.zone.ZoneOffsetTransition.isOverlap()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中org.threeten.bp.zone.ZoneOffsetTransition.isOverlap()方法的一些代码示例,展示了ZoneOffsetTransition.isOverlap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneOffsetTransition.isOverlap()方法的具体详情如下:
包路径:org.threeten.bp.zone.ZoneOffsetTransition
类名称:ZoneOffsetTransition
方法名:isOverlap

ZoneOffsetTransition.isOverlap介绍

[英]Does this transition represent a gap in the local time-line.

Overlaps occur where there are local date-times that exist twice. An example would be when the offset changes from +02:00 to +01:00. This might be described as 'the clocks will move back one hour tonight at 2am'.
[中]这种转变是否代表了当地时间线的差距。
如果存在两次本地日期时间,则会发生重叠。例如,偏移从+02:00更改为+01:00。这可以被描述为“今晚凌晨2点钟会向后拨一小时”。

代码示例

代码示例来源:origin: stackoverflow.com

public boolean isExtraHour(final ZonedDateTime time) {
  final ZoneOffsetTransition dayTransition = time.getZone().getRules()
      .getTransition(time.toLocalDateTime());

  return dayTransition != null && dayTransition.isOverlap() && dayTransition.getInstant()
      .equals(time.toInstant());
}

代码示例来源:origin: org.threeten/threetenbp

@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<D>(dateTime, earlierOffset, zone);
    }
  }
  return this;
}

代码示例来源:origin: ThreeTen/threetenbp

@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<D>(dateTime, earlierOffset, zone);
    }
  }
  return this;
}

代码示例来源:origin: ThreeTen/threetenbp

/**
 * Returns a copy of this date-time changing the zone offset to the
 * earlier of the two valid offsets at a local time-line overlap.
 * <p>
 * This method only has any effect when the local time-line overlaps, such as
 * at an autumn daylight savings cutover. In this scenario, there are two
 * valid offsets for the local date-time. Calling this method will return
 * a zoned date-time with the earlier of the two selected.
 * <p>
 * If this method is called when it is not an overlap, {@code this}
 * is returned.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @return a {@code ZonedDateTime} based on this date-time with the earlier offset, not null
 */
@Override
public ZonedDateTime withEarlierOffsetAtOverlap() {
  ZoneOffsetTransition trans = getZone().getRules().getTransition(dateTime);
  if (trans != null && trans.isOverlap()) {
    ZoneOffset earlierOffset = trans.getOffsetBefore();
    if (earlierOffset.equals(offset) == false) {
      return new ZonedDateTime(dateTime, earlierOffset, zone);
    }
  }
  return this;
}

代码示例来源:origin: org.threeten/threetenbp

/**
 * Returns a copy of this date-time changing the zone offset to the
 * earlier of the two valid offsets at a local time-line overlap.
 * <p>
 * This method only has any effect when the local time-line overlaps, such as
 * at an autumn daylight savings cutover. In this scenario, there are two
 * valid offsets for the local date-time. Calling this method will return
 * a zoned date-time with the earlier of the two selected.
 * <p>
 * If this method is called when it is not an overlap, {@code this}
 * is returned.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @return a {@code ZonedDateTime} based on this date-time with the earlier offset, not null
 */
@Override
public ZonedDateTime withEarlierOffsetAtOverlap() {
  ZoneOffsetTransition trans = getZone().getRules().getTransition(dateTime);
  if (trans != null && trans.isOverlap()) {
    ZoneOffset earlierOffset = trans.getOffsetBefore();
    if (earlierOffset.equals(offset) == false) {
      return new ZonedDateTime(dateTime, earlierOffset, zone);
    }
  }
  return this;
}

相关文章