本文整理了Java中java.time.zone.ZoneRules.getStandardOffset()
方法的一些代码示例,展示了ZoneRules.getStandardOffset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneRules.getStandardOffset()
方法的具体详情如下:
包路径:java.time.zone.ZoneRules
类名称:ZoneRules
方法名:getStandardOffset
[英]Gets the standard offset for the specified instant in this zone.
This provides access to historic information on how the standard offset has changed over time. The standard offset is the offset before any daylight saving time is applied. This is typically the offset applicable during winter.
[中]获取此区域中指定瞬间的标准偏移量。
这样就可以访问有关标准偏移如何随时间变化的历史信息。标准偏移是应用任何夏令时之前的偏移。这通常是冬季适用的补偿。
代码示例来源:origin: io.airlift/joda-to-java-time-bridge
@Override
public int getStandardOffset(long instant)
{
return zoneRules.getStandardOffset(Instant.ofEpochMilli(instant)).getTotalSeconds() * 1000;
}
代码示例来源:origin: goldmansachs/jdmn
public static OffsetTime makeOffsetTime(String literal) {
literal = DateTimeUtil.fixDateTimeFormat(literal);
if (!DateTimeUtil.isTime(literal)) {
return null;
}
if (DateTimeUtil.hasZone(literal) && DateTimeUtil.timeHasOffset(literal)) {
return null;
}
if (DateTimeUtil.hasZone(literal)) {
if (literal.contains("@")) {
int zoneIndex = literal.indexOf("@");
String zoneId = literal.substring(literal.indexOf('@') + 1);
ZoneId zone = ZoneId.of(zoneId);
LocalTime localTime = LocalTime.parse(literal.substring(0, zoneIndex), FEEL_TIME_FORMAT);
ZonedDateTime zdt = ZonedDateTime.of(LocalDate.now(zone), localTime, zone);
ZoneOffset offset = zone.getRules().getStandardOffset(zdt.toInstant());
return localTime.atOffset(offset);
} else {
return OffsetTime.parse(literal);
}
} else if (DateTimeUtil.hasOffset(literal)) {
return OffsetTime.parse(literal);
} else {
return OffsetTime.parse(literal + "Z");
}
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
public static OffsetTime makeOffsetTime(String literal) {
literal = DateTimeUtil.fixDateTimeFormat(literal);
if (!DateTimeUtil.isTime(literal)) {
return null;
}
if (DateTimeUtil.hasZone(literal) && DateTimeUtil.timeHasOffset(literal)) {
return null;
}
if (DateTimeUtil.hasZone(literal)) {
if (literal.contains("@")) {
int zoneIndex = literal.indexOf("@");
String zoneId = literal.substring(literal.indexOf('@') + 1);
ZoneId zone = ZoneId.of(zoneId);
LocalTime localTime = LocalTime.parse(literal.substring(0, zoneIndex), FEEL_TIME_FORMAT);
ZonedDateTime zdt = ZonedDateTime.of(LocalDate.now(zone), localTime, zone);
ZoneOffset offset = zone.getRules().getStandardOffset(zdt.toInstant());
return localTime.atOffset(offset);
} else {
return OffsetTime.parse(literal);
}
} else if (DateTimeUtil.hasOffset(literal)) {
return OffsetTime.parse(literal);
} else {
return OffsetTime.parse(literal + "Z");
}
}
内容来源于网络,如有侵权,请联系作者删除!