本文整理了Java中org.threeten.bp.zone.ZoneRules.isDaylightSavings()
方法的一些代码示例,展示了ZoneRules.isDaylightSavings()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneRules.isDaylightSavings()
方法的具体详情如下:
包路径:org.threeten.bp.zone.ZoneRules
类名称: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;
}
内容来源于网络,如有侵权,请联系作者删除!