gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-16 16:38:40 29 4
gpt4 key购买 nike

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

ZoneRules.nextTransition介绍

[英]Gets the next transition after the specified instant.

This returns details of the next transition after the specified instant. For example, if the instant represents a point where "Summer" daylight savings time applies, then the method will return the transition to the next "Winter" time.
[中]获取指定瞬间之后的下一个转换。
这将返回指定瞬间之后下一次转换的详细信息。例如,如果该瞬间表示应用“夏季”夏令时的点,则该方法将返回到下一个“冬季”时间的转换。

代码示例

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

assertTrue(immutability.test(YearMonth.now()));
assertTrue(immutability.test(ZoneOffset.UTC));
assertTrue(immutability.test(ZoneRules.of(ZoneOffset.UTC).nextTransition(Instant.now())));
assertTrue(immutability.test(ZoneOffsetTransitionRule.of(Month.JANUARY, 1, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.STANDARD, ZoneOffset.UTC, ZoneOffset.ofHours(1), ZoneOffset.ofHours(2))));
assertTrue(immutability.test(ZoneRules.of(ZoneOffset.UTC)));

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

ZoneId zoneId = ZoneId.of("Australia/Sydney");
ZoneRules rules = zoneId.getRules();

ZoneOffsetTransition nextTransition = rules.nextTransition(Instant.now());
System.out.println("Next transition at: " +
    nextTransition.getInstant().atZone(zoneId));

ZoneOffsetTransition nextNextTransition =
    rules.nextTransition(nextTransition.getInstant());
System.out.println("Next transition after that at: " +
    nextNextTransition.getInstant().atZone(zoneId));

代码示例来源:origin: com.vaadin/vaadin-server

while (true) {
  ZoneOffsetTransition t = rules
      .nextTransition(i.toInstant());
  if (t == null) {
    break;

代码示例来源:origin: io.airlift/joda-to-java-time-bridge

@Override
public long nextTransition(long instant)
{
  ZoneOffsetTransition nextTransition = zoneRules.nextTransition(Instant.ofEpochMilli(instant));
  if (nextTransition == null) {
    // this is after the last transition
    return instant;
  }
  return nextTransition.toEpochSecond() * 1000;
}

代码示例来源:origin: jpos/jPOS

p.printf("%s         rule: %s%n", indent, tr.toString());
ZoneOffsetTransition tran = zi.getRules().nextTransition(instant);
if (tran != null) {
  Instant in = tran.getInstant();

代码示例来源:origin: jpos/jPOS

public void exec(CLIContext cli, String[] args) throws Exception
  {
    ZoneId zi = ZoneId.systemDefault();
    Instant i = Instant.now();
    cli.println(
      "         Zone ID: " + zi + " (" + zi.getDisplayName(TextStyle.FULL, Locale.getDefault()) + ") "
        + zi.getRules().getOffset(i)
    );
    cli.println ("             UTC: " + i);
    ZoneOffsetTransition tran = zi.getRules().nextTransition(i);
    if (tran != null) {
      Instant in = tran.getInstant();
      cli.println (" Next transition: " + in + " (" + in.atZone(zi) + ")");
    }
    List<ZoneOffsetTransitionRule> l = zi.getRules().getTransitionRules();
    for (ZoneOffsetTransitionRule r : l) {
      cli.println (" Transition rule: " + r);
    }
  }
}

代码示例来源:origin: infiniteautomation/ma-core-public

/**
   * @param zdt
   * @return
   */
  public Instant getInstant(ZonedDateTime zdt) {
    ZonedDateTime offset = zdt.withHour(hour).withMinute(minute).withSecond(second).withNano((int)(millisecond * 1000000l));
    LocalDateTime ldt = zdt.toLocalDateTime();
    ldt = ldt.withHour(hour).withMinute(minute).withSecond(second).withNano((int)(millisecond * 1000000l));
    
    if(!zdt.getZone().getRules().isValidOffset(ldt, zdt.getOffset())) {
      //Within a gap of DST so OR after the transition
      ZoneOffsetTransition transition = zdt.getZone().getRules().nextTransition(zdt.toInstant());
      if(!ldt.isAfter(transition.getDateTimeAfter())){
        //In a gap so we shift our time forward to the end of the gap.
        offset = transition.getDateTimeAfter().atZone(zdt.getZone());
      }else {
        //After a gap so ensure we use the next zone offset
        offset = ldt.atOffset(transition.getOffsetAfter()).atZoneSimilarLocal(transition.getOffsetAfter());
      }
    }
    
    return offset.toInstant();
  }
}

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