gpt4 book ai didi

java.time.zone.ZoneOffsetTransition.isGap()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 08:18:49 28 4
gpt4 key购买 nike

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

ZoneOffsetTransition.isGap介绍

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

Gaps occur where there are local date-times that simply do not not exist. An example would be when the offset changes from +01:00 to +02:00. This might be described as 'the clocks will move forward one hour tonight at 1am'.
[中]这种转变是否代表了当地时间线的差距。
当本地日期时间根本不存在时,就会出现间隔。例如,偏移从+01:00更改为+02:00。这可能被描述为“时钟将在今晚凌晨1点向前移动一小时”。

代码示例

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Returns a string describing this object.
 *
 * @return a string for debugging, not null
 */
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append("Transition[")
    .append(isGap() ? "Gap" : "Overlap")
    .append(" at ")
    .append(transition)
    .append(offsetBefore)
    .append(" to ")
    .append(offsetAfter)
    .append(']');
  return buf.toString();
}

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Gets the valid offsets during this transition.
 * <p>
 * A gap will return an empty list, while an overlap will return both offsets.
 *
 * @return the list of valid offsets
 */
List<ZoneOffset> getValidOffsets() {
  if (isGap()) {
    return Collections.emptyList();
  }
  return Arrays.asList(getOffsetBefore(), getOffsetAfter());
}

代码示例来源:origin: com.github.seratch/java-time-backport

ZoneOffset after = wallOffsets[i + 1];
ZoneOffsetTransition trans = new ZoneOffsetTransition(savingsInstantTransitions[i], before, after);
if (trans.isGap()) {
  localTransitionList.add(trans.getDateTimeBefore());
  localTransitionList.add(trans.getDateTimeAfter());

代码示例来源:origin: com.github.seratch/java-time-backport

localTransitionOffsetList.add(baseWallOffset);
for (ZoneOffsetTransition trans : transitionList) {
  if (trans.isGap()) {
    localTransitionList.add(trans.getDateTimeBefore());
    localTransitionList.add(trans.getDateTimeAfter());

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Checks if the specified offset is valid during this transition.
 * <p>
 * This checks to see if the given offset will be valid at some point in the transition.
 * A gap will always return false.
 * An overlap will return true if the offset is either the before or after offset.
 *
 * @param offset  the offset to check, null returns false
 * @return true if the offset is valid during the transition
 */
public boolean isValidOffset(ZoneOffset offset) {
  return isGap() ? false : (getOffsetBefore().equals(offset) || getOffsetAfter().equals(offset));
}

代码示例来源:origin: com.github.seratch/java-time-backport

ZoneRules rules = zone.getRules();
ZoneOffsetTransition trans = rules.getTransition(ldt);
if (trans != null && trans.isGap()) {
  ldt = trans.getDateTimeAfter();

代码示例来源:origin: com.addthis/cronus

if (transition == null) {
  return input;
} else if (transition.isGap() || zoneOffset.equals(transition.getOffsetAfter())) {
  return ZonedDateTime.ofInstant(transition.getDateTimeBefore().minusMinutes(1),
                    transition.getOffsetBefore(), zoneId);

代码示例来源:origin: com.github.seratch/java-time-backport

if (rules.isValidOffset(localDateTime, offset) == false) {
  ZoneOffsetTransition trans = rules.getTransition(localDateTime);
  if (trans != null && trans.isGap()) {

代码示例来源:origin: com.github.seratch/java-time-backport

/**
 * Finds the offset info for a local date-time and transition.
 *
 * @param dt  the date-time, not null
 * @param trans  the transition, not null
 * @return the offset info, not null
 */
private Object findOffsetInfo(LocalDateTime dt, ZoneOffsetTransition trans) {
  LocalDateTime localTransition = trans.getDateTimeBefore();
  if (trans.isGap()) {
    if (dt.isBefore(localTransition)) {
      return trans.getOffsetBefore();
    }
    if (dt.isBefore(trans.getDateTimeAfter())) {
      return trans;
    } else {
      return trans.getOffsetAfter();
    }
  } else {
    if (dt.isBefore(localTransition) == false) {
      return trans.getOffsetAfter();
    }
    if (dt.isBefore(trans.getDateTimeAfter())) {
      return trans.getOffsetBefore();
    } else {
      return trans;
    }
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com