org.threeten.bp.zone.ZoneRules.isDaylightSavings()方法的使用及代码示例

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

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

ZoneRules.isDaylightSavings介绍

[英]Checks if the specified instant is in daylight savings.

This checks if the standard and actual offsets are the same at the specified instant.
[中]检查指定的时间是否为夏令时。
这将检查在指定的瞬间标准偏移和实际偏移是否相同。

代码示例

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

ZoneRules rules = zdt.getZone().getRules();
Boolean dstInEffect = rules.isDaylightSavings( zdt.toInstant() );

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

ZonedDateTime zdt = ...;
ZoneRules rules = zdt.getZone().getRules();
boolean isDst = rules.isDaylightSavings(zdt.toInstant());

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

ZonedDateTime now = ZonedDateTime.now( ZoneId.of( "America/Montreal" ) );
…
ZoneId z = now.getZone();
ZoneRules zoneRules = z.getRules();
Boolean isDst = zoneRules.isDaylightSavings( now.toInstant() );

代码示例来源:origin: ThreeTen/threetenbp

@Override
public boolean print(DateTimePrintContext context, StringBuilder buf) {
  ZoneId zone = context.getValue(TemporalQueries.zoneId());
  if (zone == null) {
    return false;
  }
  if (zone.normalized() instanceof ZoneOffset) {
    buf.append(zone.getId());
    return true;
  }
  TemporalAccessor temporal = context.getTemporal();
  boolean daylight = false;
  if (temporal.isSupported(INSTANT_SECONDS)) {
    Instant instant = Instant.ofEpochSecond(temporal.getLong(INSTANT_SECONDS));
    daylight = zone.getRules().isDaylightSavings(instant);
  }
  TimeZone tz = TimeZone.getTimeZone(zone.getId());
  int tzstyle = (textStyle.asNormal() == TextStyle.FULL ? TimeZone.LONG : TimeZone.SHORT);
  String text = tz.getDisplayName(daylight, tzstyle, context.getLocale());
  buf.append(text);
  return true;
}

代码示例来源:origin: org.threeten/threetenbp

@Override
public boolean print(DateTimePrintContext context, StringBuilder buf) {
  ZoneId zone = context.getValue(TemporalQueries.zoneId());
  if (zone == null) {
    return false;
  }
  if (zone.normalized() instanceof ZoneOffset) {
    buf.append(zone.getId());
    return true;
  }
  TemporalAccessor temporal = context.getTemporal();
  boolean daylight = false;
  if (temporal.isSupported(INSTANT_SECONDS)) {
    Instant instant = Instant.ofEpochSecond(temporal.getLong(INSTANT_SECONDS));
    daylight = zone.getRules().isDaylightSavings(instant);
  }
  TimeZone tz = TimeZone.getTimeZone(zone.getId());
  int tzstyle = (textStyle.asNormal() == TextStyle.FULL ? TimeZone.LONG : TimeZone.SHORT);
  String text = tz.getDisplayName(daylight, tzstyle, context.getLocale());
  buf.append(text);
  return true;
}

相关文章

微信公众号

最新文章

更多