org.threeten.bp.OffsetDateTime.withOffsetSameInstant()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.3k)|赞(0)|评价(0)|浏览(134)

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

OffsetDateTime.withOffsetSameInstant介绍

[英]Returns a copy of this OffsetDateTime with the specified offset ensuring that the result is at the same instant.

This method returns an object with the specified ZoneOffset and a LocalDateTimeadjusted by the difference between the two offsets. This will result in the old and new objects representing the same instant. This is useful for finding the local time in a different offset. For example, if this time represents 2007-12-23T10:30+02:00 and the offset specified is +03:00, then this method will return 2007-12-23T11:30+03:00.

To change the offset without adjusting the local time use #withOffsetSameLocal.

This instance is immutable and unaffected by this method call.
[中]返回具有指定偏移量的此OffsetDateTime的副本,确保结果在同一时刻。
此方法返回具有指定ZoneOffset和LocalDateTimeadjusted(由两个偏移量之间的差值调整)的对象。这将导致新旧对象代表同一时刻。这对于在不同偏移中查找本地时间很有用。例如,如果此时间表示2007-12-23T10:30+02:00,且指定的偏移量为+03:00,则此方法将返回2007-12-23T11:30+03:00。
要更改偏移量而不调整本地时间,请使用#withOffsetSameLocal。
此实例是不可变的,不受此方法调用的影响。

代码示例

代码示例来源:origin: gengstrand/clojure-news-feed

@Override
 public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
  return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
 }
}

代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp

@Override
  public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
    return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
  }
},

代码示例来源:origin: XeroAPI/Xero-Java

@Override
 public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
  return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
 }
}

代码示例来源:origin: mercadolibre/java-sdk

@Override
 public OffsetDateTime apply(OffsetDateTime d, ZoneId z) {
  return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime()));
 }
}

代码示例来源:origin: ThreeTen/threetenbp

OffsetDateTime end = OffsetDateTime.from(endExclusive);
if (unit instanceof ChronoUnit) {
  end = end.withOffsetSameInstant(offset);
  return dateTime.until(end.dateTime, unit);

代码示例来源:origin: org.threeten/threetenbp

OffsetDateTime end = OffsetDateTime.from(endExclusive);
if (unit instanceof ChronoUnit) {
  end = end.withOffsetSameInstant(offset);
  return dateTime.until(end.dateTime, unit);

相关文章