本文整理了Java中java.time.ZonedDateTime.withFixedOffsetZone()
方法的一些代码示例,展示了ZonedDateTime.withFixedOffsetZone()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonedDateTime.withFixedOffsetZone()
方法的具体详情如下:
包路径:java.time.ZonedDateTime
类名称:ZonedDateTime
方法名:withFixedOffsetZone
[英]Returns a copy of this date-time with the zone ID set to the offset.
This returns a zoned date-time where the zone ID is the same as #getOffset(). The local date-time, offset and instant of the result will be the same as in this date-time.
Setting the date-time to a fixed single offset means that any future calculations, such as addition or subtraction, have no complex edge cases due to time-zone rules. This might also be useful when sending a zoned date-time across a network, as most protocols, such as ISO-8601, only handle offsets, and not region-based zone IDs.
This is equivalent to ZonedDateTime.of(zdt.getDateTime(), zdt.getOffset()).
[中]返回此日期时间的副本,区域ID设置为偏移量。
这将返回一个分区日期时间,其中分区ID与#getOffset()相同。结果的本地日期时间、偏移量和瞬间将与此日期时间相同。
将日期-时间设置为固定的单个偏移量意味着未来的任何计算(如加法或减法)都不会因时区规则而出现复杂的边缘情况。当通过网络发送分区日期时间时,这可能也很有用,因为大多数协议(如ISO-8601)只处理偏移,而不处理基于区域的分区ID。
这相当于ZoneDateTime。of(zdt.getDateTime(),zdt。getOffset())。
代码示例来源:origin: org.elasticsearch/elasticsearch
public ZonedDateTime withFixedOffsetZone() {
return dt.withFixedOffsetZone();
}
代码示例来源:origin: eclipse/smarthome
public DateTimeType(ZonedDateTime zoned) {
this.zonedDateTime = ZonedDateTime.from(zoned).withFixedOffsetZone();
}
代码示例来源:origin: eclipse/smarthome
/**
* @deprecated The constructor uses Calendar object hence it doesn't store time zone. A new constructor is
* available. Use {@link #DateTimeType(ZonedDateTime)} instead.
*
* @param calendar The Calendar object containing the time stamp.
*/
@Deprecated
public DateTimeType(Calendar calendar) {
this.zonedDateTime = ZonedDateTime.ofInstant(calendar.toInstant(), TimeZone.getDefault().toZoneId())
.withFixedOffsetZone();
}
代码示例来源:origin: apache/servicemix-bundles
public ZonedDateTime withFixedOffsetZone() {
return dt.withFixedOffsetZone();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
public ZonedDateTime withFixedOffsetZone() {
return dt.withFixedOffsetZone();
}
代码示例来源:origin: openhab/openhab-core
public DateTimeType(ZonedDateTime zoned) {
this.zonedDateTime = ZonedDateTime.from(zoned).withFixedOffsetZone();
}
代码示例来源:origin: openhab/openhab-core
/**
* @deprecated The constructor uses Calendar object hence it doesn't store time zone. A new constructor is
* available. Use {@link #DateTimeType(ZonedDateTime)} instead.
*
* @param calendar The Calendar object containing the time stamp.
*/
@Deprecated
public DateTimeType(Calendar calendar) {
this.zonedDateTime = ZonedDateTime.ofInstant(calendar.toInstant(), TimeZone.getDefault().toZoneId())
.withFixedOffsetZone();
}
内容来源于网络,如有侵权,请联系作者删除!