假设我有一个 ZonedDateTime:
ZonedDateTime zonedDateTime =
ZonedDateTime.of(LocalDateTime.now(), ZoneId.of("US/Pacific"));
Run Code Online (Sandbox Code Playgroud)
我想知道它是在柏林的哪个日期/时间。我有两种方法:
zonedDateTime.withZoneSameInstant(ZoneId.of("Europe/Berlin")); // probably this is the right one to get the corresponding date/time in Berlin
zonedDateTime.withZoneSameLocal(ZoneId.of("Europe/Berlin"));
Run Code Online (Sandbox Code Playgroud)
该withZoneSameLocal方法的文档说:“仅当本地日期时间对新区域无效时才会更改......”并且不清楚何时真的会发生(任何示例?=))。
它们各自代表哪个日期/时间,有什么区别?