gpt4 book ai didi

java.time.ZonedDateTime.withFixedOffsetZone()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 18:16:40 33 4
gpt4 key购买 nike

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

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();
}

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com