gpt4 book ai didi

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

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

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

ZonedDateTime.withEarlierOffsetAtOverlap介绍

[英]Returns a copy of this date-time changing the zone offset to the earlier of the two valid offsets at a local time-line overlap.

This method only has any effect when the local time-line overlaps, such as at an autumn daylight savings cutover. In this scenario, there are two valid offsets for the local date-time. Calling this method will return a zoned date-time with the earlier of the two selected.

If this method is called when it is not an overlap, thisis returned.

This instance is immutable and unaffected by this method call.
[中]返回此日期时间的副本,将分区偏移更改为本地时间线重叠处两个有效偏移中的较早者。
此方法仅在本地时间线重叠时有效,例如在秋季夏令时切换时。在这种情况下,本地日期时间有两个有效的偏移量。调用此方法将返回一个分区日期时间,并选择两者中较早的一个。
如果在不重叠的情况下调用此方法,则返回this。
此实例是不可变的,不受此方法调用的影响。

代码示例

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

DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder();
dtfb.append(DateTimeFormatter.ISO_LOCAL_DATE);
dtfb.appendLiteral(' ');
dtfb.append(DateTimeFormatter.ISO_LOCAL_TIME);
DateTimeFormatter dtf = dtfb.toFormatter();
ZoneId shanghai = ZoneId.of("Asia/Shanghai");

String str3 = "1927-12-31 23:54:07";  
String str4 = "1927-12-31 23:54:08";  

ZonedDateTime zdt3 = LocalDateTime.parse(str3, dtf).atZone(shanghai);
ZonedDateTime zdt4 = LocalDateTime.parse(str4, dtf).atZone(shanghai);

Duration durationAtEarlierOffset = Duration.between(zdt3.withEarlierOffsetAtOverlap(), zdt4.withEarlierOffsetAtOverlap());

Duration durationAtLaterOffset = Duration.between(zdt3.withLaterOffsetAtOverlap(), zdt4.withLaterOffsetAtOverlap());

代码示例来源:origin: org.elasticsearch/elasticsearch

public ZonedDateTime withEarlierOffsetAtOverlap() {
  return dt.withEarlierOffsetAtOverlap();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

public ZonedDateTime withEarlierOffsetAtOverlap() {
  return dt.withEarlierOffsetAtOverlap();
}

代码示例来源:origin: apache/servicemix-bundles

public ZonedDateTime withEarlierOffsetAtOverlap() {
  return dt.withEarlierOffsetAtOverlap();
}

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