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

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

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

ZoneRules.getDaylightSavings介绍

[英]Gets the amount of daylight savings in use for the specified instant in this zone.

This provides access to historic information on how the amount of daylight savings has changed over time. This is the difference between the standard offset and the actual offset. Typically the amount is zero during winter and one hour during summer. Time-zones are second-based, so the nanosecond part of the duration will be zero.
[中]获取此区域中指定时刻的夏时制使用量。
这提供了有关夏令时数量随时间变化的历史信息。这是标准偏移和实际偏移之间的差异。通常情况下,冬季为零,夏季为一小时。时区是以秒为基础的,因此持续时间的纳秒部分将为零。

代码示例

代码示例来源:origin: alblue/com.packtpub.e4

public String getText(Object element) {
  if (element instanceof ZoneId) {
    return String.valueOf(!((ZoneId) element).getRules().getDaylightSavings(Instant.now()).isZero());
  } else {
    return "";
  }
}

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

int previousOffset = zot.getOffsetBefore().getTotalSeconds();
int totalOffset = zot.getOffsetAfter().getTotalSeconds();
int dst = Math.toIntExact(zoneRules.getDaylightSavings(instant).getSeconds());
transitions.add(new ZonalTransition(posixTime, previousOffset, totalOffset, dst));

相关文章