net.time4j.tz.ZonalTransition.getTotalOffset()方法的使用及代码示例

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

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

ZonalTransition.getTotalOffset介绍

[英]Returns the total shift after this transition.
[中]返回此转换后的总班次。

代码示例

代码示例来源:origin: net.time4j/time4j-olson

@Override
public ZonalOffset getInitialOffset() {
  return ZonalOffset.ofTotalSeconds(this.initial.getTotalOffset());
}

代码示例来源:origin: net.time4j/time4j-core

@Override
public ZonalOffset getOffset(
  GregorianDate localDate,
  WallTime localTime
) {
  List<ZonalOffset> offsets =
    this.history.getValidOffsets(localDate, localTime);
  if (offsets.size() == 1) {
    return offsets.get(0);
  } else {
    ZonalTransition conflict = this.history.getConflictTransition(localDate, localTime);
    return ZonalOffset.ofTotalSeconds(conflict.getTotalOffset());
  }
}

代码示例来源:origin: net.time4j/time4j-olson

static void dump(
  ZonalTransition transition,
  Appendable buffer
) throws IOException {
  Moment ut = Moment.of(transition.getPosixTime(), TimeScale.POSIX);
  buffer.append(">>> Transition at: ").append(ut.toString());
  buffer.append(" from ").append(format(transition.getPreviousOffset()));
  buffer.append(" to ").append(format(transition.getTotalOffset()));
  buffer.append(", DST=");
  buffer.append(format(transition.getDaylightSavingOffset()));
  buffer.append(NEW_LINE);
}

代码示例来源:origin: net.time4j/time4j-olson

private static int searchLocal(
  long localSecs,
  ZonalTransition[] transitions
) {
  int low = 0;
  int high = transitions.length - 1;
  while (low <= high) {
    int middle = (low + high) / 2;
    ZonalTransition zt = transitions[middle];
    int offset = Math.max(zt.getTotalOffset(), zt.getPreviousOffset());
    if (zt.getPosixTime() + offset <= localSecs) {
      low = middle + 1;
    } else {
      high = middle - 1;
    }
  }
  return low;
}

代码示例来源:origin: net.time4j/time4j-olson

static void checkSanity(
  ZonalTransition[] transitions,
  List<ZonalTransition> original
) {
  int previous = transitions[0].getTotalOffset();
  for (int i = 1; i < transitions.length; i++) {
    if (previous != transitions[i].getPreviousOffset()) {
      Moment m =
        Moment.of(transitions[i].getPosixTime(), TimeScale.POSIX);
      throw new IllegalArgumentException(
        "Model inconsistency detected at: " + m
        + " (" + transitions[i].getPosixTime() + ") "
        + " in transitions: " + original);
    } else {
      previous = transitions[i].getTotalOffset();
    }
  }
}

代码示例来源:origin: net.time4j/time4j-core

@Override
public ZonalOffset getOffset(UnixTime ut) {
  ZonalTransition t = this.history.getStartTransition(ut);
  return (
    (t == null)
    ? this.history.getInitialOffset()
    : ZonalOffset.ofTotalSeconds(t.getTotalOffset())
  );
}

代码示例来源:origin: net.time4j/time4j-olson

ZonalTransition getConflictTransition(
  GregorianDate localDate,
  long localSecs
) {
  long preModel = this.initial.getPosixTime();
  int max =
    Math.max(
      this.initial.getPreviousOffset(),
      this.initial.getTotalOffset());
  if (localSecs <= preModel + max) {
    return null;
  }
  for (ZonalTransition t : this.getTransitions(localDate)) {
    long tt = t.getPosixTime();
    if (t.isGap()) {
      if (localSecs < tt + t.getPreviousOffset()) {
        return null; // offset = t.getPreviousOffset()
      } else if (localSecs < tt + t.getTotalOffset()) {
        return t;
      }
    } else if (t.isOverlap()) {
      if (localSecs < tt + t.getTotalOffset()) {
        return null; // offset = t.getPreviousOffset()
      } else if (localSecs < tt + t.getPreviousOffset()) {
        return t;
      }
    }
  }
  return null; // offset = lastTotalOffset
}

代码示例来源:origin: net.time4j/time4j-olson

private static void writeRuleBasedTransitionModel(
  Object obj,
  ObjectOutput out
) throws IOException {
  RuleBasedTransitionModel model = (RuleBasedTransitionModel) obj;
  ZonalTransition initial = model.getInitialTransition();
  long posixTime = initial.getPosixTime();
  if (
    (posixTime >= POSIX_TIME_1825)
    && (posixTime < POSIX_TIME_1825 + QUARTERS_IN_24_BITS)
    && ((posixTime % 900) == 0)
  ) {
    int data = (int) ((posixTime - POSIX_TIME_1825) / 900);
    out.writeByte((data >>> 16) & 0xFF);
    out.writeByte((data >>> 8) & 0xFF);
    out.writeByte(data & 0xFF);
  } else {
    out.writeByte(0xFF);
    out.writeLong(initial.getPosixTime());
  }
  writeOffset(out, initial.getPreviousOffset());
  writeOffset(out, initial.getTotalOffset());
  int dst = initial.getDaylightSavingOffset();
  if (initial.isDaylightSaving() && (dst == 0)) {
    dst = Integer.MAX_VALUE;
  }
  writeOffset(out, dst);
  writeRules(model.getRules(), out);
}

代码示例来源:origin: net.time4j/time4j-olson

ZonalTransition first =
  getNextTransition(initial.getPosixTime(), initial, sortedRules);
if (initial.getTotalOffset() != first.getPreviousOffset()) {
  throw new IllegalArgumentException(
    "Inconsistent model: " + initial + " / " + rules);

代码示例来源:origin: net.time4j/time4j-olson

ZonalTransition last =
    this.transitions[this.transitions.length - 1];
  return TransitionModel.toList(last.getTotalOffset());
} else {
  return ruleModel.getValidOffsets(localDate, localSecs);
assert (test.getPosixTime() + test.getTotalOffset() > localSecs);
if (test.getPosixTime() + test.getPreviousOffset() <= localSecs) {
  return Collections.emptyList();
if (test.getPosixTime() + test.getTotalOffset() <= localSecs) {
  return TransitionModel.toList(
    test.getTotalOffset(),
    test.getPreviousOffset());

代码示例来源:origin: net.time4j/time4j-core

long localSeconds = toLocalSeconds(y, m, d, h, min, s);
    localSeconds += conflict.getSize();
    return localSeconds - conflict.getTotalOffset();
  case NEXT_VALID_TIME:
    return conflict.getPosixTime();
int offset = conflict.getTotalOffset();
if (this.overlapResolver == OverlapResolver.EARLIER_OFFSET) {
  offset = conflict.getPreviousOffset();

代码示例来源:origin: net.time4j/time4j-olson

List<ZonalOffset> getValidOffsets(
  GregorianDate localDate,
  long localSecs
) {
  long preModel = this.initial.getPosixTime();
  int last = this.initial.getTotalOffset();
  int max = Math.max(this.initial.getPreviousOffset(), last);
  if (localSecs <= preModel + max) {
    return TransitionModel.toList(last);
  }
  for (ZonalTransition t : this.getTransitions(localDate)) {
    long tt = t.getPosixTime();
    last = t.getTotalOffset();
    if (t.isGap()) {
      if (localSecs < tt + t.getPreviousOffset()) {
        return TransitionModel.toList(t.getPreviousOffset());
      } else if (localSecs < tt + last) {
        return Collections.emptyList();
      }
    } else if (t.isOverlap()) {
      if (localSecs < tt + last) {
        return TransitionModel.toList(t.getPreviousOffset());
      } else if (localSecs < tt + t.getPreviousOffset()) {
        return TransitionModel.toList(last, t.getPreviousOffset());
      }
    }
  }
  return TransitionModel.toList(last);
}

代码示例来源:origin: net.time4j/time4j-olson

assert (test.getPosixTime() + test.getTotalOffset() > localSecs);
if (test.getPosixTime() + test.getPreviousOffset() <= localSecs) {
  return test;
if (test.getPosixTime() + test.getTotalOffset() <= localSecs) {
  return test;

代码示例来源:origin: net.time4j/time4j-core

private PlainTimestamp atStartOfDay(TransitionHistory history) {
  if (history == null) {
    throw new UnsupportedOperationException(
      "Timezone repository does not expose its transition history: "
      + Timezone.getProviderInfo());
  }
  ZonalTransition conflict = history.getConflictTransition(this, PlainTime.MIN);
  if ((conflict != null) && conflict.isGap()) {
    long localSeconds =
      conflict.getPosixTime() + conflict.getTotalOffset();
    PlainDate date =
      PlainDate.of(
        MathUtils.floorDivide(localSeconds, 86400),
        EpochDays.UNIX);
    int secondsOfDay = MathUtils.floorModulo(localSeconds, 86400);
    int second = secondsOfDay % 60;
    int minutesOfDay = secondsOfDay / 60;
    int minute = minutesOfDay % 60;
    int hour = minutesOfDay / 60;
    PlainTime time = PlainTime.of(hour, minute, second);
    return PlainTimestamp.of(date, time);
  }
  return this.at(PlainTime.MIN);
}

代码示例来源:origin: net.time4j/time4j-core

int offset = conflict.getTotalOffset();
if (conflict.isGap()) {
  if (this.gapResolver == GapResolver.ABORT) {

相关文章