gpt4 book ai didi

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

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

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

ZoneOffsetTransition.getDateTimeBefore介绍

[英]Gets the local transition date-time, as would be expressed with the 'before' offset.

This is the date-time where the discontinuity begins expressed with the 'before' offset. At this instant, the 'after' offset is actually used, therefore the combination of this date-time and the 'before' offset will never occur.

The combination of the 'before' date-time and offset represents the same instant as the 'after' date-time and offset.
[中]获取本地转换日期时间,用“before”偏移量表示。
这是不连续开始的日期时间,用“之前”偏移量表示。此时,实际使用的是“之后”偏移量,因此该日期时间和“之前”偏移量的组合将永远不会出现。
“之前”日期时间和偏移量的组合表示与“之后”日期时间和偏移量相同的时刻。

代码示例

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

ZoneOffsetTransition trans = new ZoneOffsetTransition(savingsInstantTransitions[i], before, after);
if (trans.isGap()) {
  localTransitionList.add(trans.getDateTimeBefore());
  localTransitionList.add(trans.getDateTimeAfter());
} else {
  localTransitionList.add(trans.getDateTimeAfter());
  localTransitionList.add(trans.getDateTimeBefore());

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

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

代码示例来源:origin: ical4j/ical4j

private static void addTransitions(ZoneId zoneId, VTimeZone result, int rawTimeZoneOffsetInSeconds) throws ParseException {
  Map<ZoneOffsetKey, Set<ZoneOffsetTransition>> zoneTransitionsByOffsets = new HashMap<ZoneOffsetKey, Set<ZoneOffsetTransition>>();
  for (ZoneOffsetTransition zoneTransitionRule : zoneId.getRules().getTransitions()) {
    ZoneOffsetKey offfsetKey = ZoneOffsetKey.of(zoneTransitionRule.getOffsetBefore(), zoneTransitionRule.getOffsetAfter());
    Set<ZoneOffsetTransition> transitionRulesForOffset = zoneTransitionsByOffsets.computeIfAbsent(offfsetKey, k -> new HashSet<ZoneOffsetTransition>(1));
    transitionRulesForOffset.add(zoneTransitionRule);
  }
  for (Map.Entry<ZoneOffsetKey, Set<ZoneOffsetTransition>> e : zoneTransitionsByOffsets.entrySet()) {
    Observance observance = (e.getKey().offsetAfter.getTotalSeconds() > rawTimeZoneOffsetInSeconds) ? new Daylight() : new Standard();
    LocalDateTime start = Collections.min(e.getValue()).getDateTimeBefore();
    DtStart dtStart = new DtStart(start.format(DateTimeFormatter.ofPattern(DATE_TIME_TPL)));
    TzOffsetFrom offsetFrom = new TzOffsetFrom(e.getKey().offsetBefore);
    TzOffsetTo offsetTo = new TzOffsetTo(e.getKey().offsetAfter);
    observance.getProperties().add(dtStart);
    observance.getProperties().add(offsetFrom);
    observance.getProperties().add(offsetTo);
    for (ZoneOffsetTransition transition : e.getValue()) {
      RDate rDate = new RDate(new ParameterList(), transition.getDateTimeBefore().format(DateTimeFormatter.ofPattern(DATE_TIME_TPL)));
      observance.getProperties().add(rDate);
    }
    result.getObservances().add(observance);
  }
}

代码示例来源:origin: org.mnode.ical4j/ical4j

private static void addTransitions(ZoneId zoneId, VTimeZone result, int rawTimeZoneOffsetInSeconds) throws ParseException {
  Map<ZoneOffsetKey, Set<ZoneOffsetTransition>> zoneTransitionsByOffsets = new HashMap<ZoneOffsetKey, Set<ZoneOffsetTransition>>();
  for (ZoneOffsetTransition zoneTransitionRule : zoneId.getRules().getTransitions()) {
    ZoneOffsetKey offfsetKey = ZoneOffsetKey.of(zoneTransitionRule.getOffsetBefore(), zoneTransitionRule.getOffsetAfter());
    Set<ZoneOffsetTransition> transitionRulesForOffset = zoneTransitionsByOffsets.computeIfAbsent(offfsetKey, k -> new HashSet<ZoneOffsetTransition>(1));
    transitionRulesForOffset.add(zoneTransitionRule);
  }
  for (Map.Entry<ZoneOffsetKey, Set<ZoneOffsetTransition>> e : zoneTransitionsByOffsets.entrySet()) {
    Observance observance = (e.getKey().offsetAfter.getTotalSeconds() > rawTimeZoneOffsetInSeconds) ? new Daylight() : new Standard();
    LocalDateTime start = Collections.min(e.getValue()).getDateTimeBefore();
    DtStart dtStart = new DtStart(start.format(DateTimeFormatter.ofPattern(DATE_TIME_TPL)));
    TzOffsetFrom offsetFrom = new TzOffsetFrom(e.getKey().offsetBefore);
    TzOffsetTo offsetTo = new TzOffsetTo(e.getKey().offsetAfter);
    observance.getProperties().add(dtStart);
    observance.getProperties().add(offsetFrom);
    observance.getProperties().add(offsetTo);
    for (ZoneOffsetTransition transition : e.getValue()) {
      RDate rDate = new RDate(new ParameterList(), transition.getDateTimeBefore().format(DateTimeFormatter.ofPattern(DATE_TIME_TPL)));
      observance.getProperties().add(rDate);
    }
    result.getObservances().add(observance);
  }
}

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

/**
 * If we are in the duplicated time period of an overlap transition,
 * then move forwards around the duplicated time period.
 */
private ZonedDateTime inputDaylightSavingsNext(ZonedDateTime input) {
  ZoneId zoneId = input.getZone();
  ZoneRules zoneRules = zoneId.getRules();
  ZoneOffset zoneOffset = input.getOffset();
  LocalDateTime localDateTime = input.toLocalDateTime();
  ZoneOffsetTransition transition = zoneRules.getTransition(localDateTime);
  if (transition == null) {
    return input;
  } else if (zoneOffset.equals(transition.getOffsetAfter())) {
    return ZonedDateTime.ofInstant(transition.getDateTimeBefore(),
                    transition.getOffsetAfter(), zoneId);
  } else {
    return input;
  }
}

代码示例来源:origin: ical4j/ical4j

startDate = zoneOffsetTransition.getDateTimeBefore();
} else {
  startDate = LocalDateTime.now(zoneId);

代码示例来源:origin: org.mnode.ical4j/ical4j

startDate = zoneOffsetTransition.getDateTimeBefore();
} else {
  startDate = LocalDateTime.now(zoneId);

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

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

代码示例来源: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;
    }
  }
}

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