java 8 时区 Australia/Melbourne 的日期时间夏令时问题
Date time day light saving issue in java 8 for time zone Australia/Melbourne
我得到夏令时开始和结束的不同结果。
ZoneId zone = ZoneId.of("Australia/Melbourne");
System.out.println(ZonedDateTime.of(2019, 04, 07, 3, 0, 0, 0, zone)); // statement-1
System.out.println(ZonedDateTime.of(2019, 10, 06, 2, 0, 0, 0, zone)); // statement-2
对于 2019 年上半年的夏令时,我得到的结果是 (2019-04-07T03:00**+10:00**[Australia/Melbourne])。 Java 正在减少 1 小时以补偿值。但是对于下半天节电 (statement-2=> 2019-10-06T03:00+11:00[Australia/Melbourne]) , java时间增加 1 小时,偏移值增加 1。
根据我的理解 java 应该增加 1 小时到时间和 +1 到偏移值(DST 结束),而 DST 开始时 java 应该从时间减少 1 小时和 1从偏移值。
请帮我澄清一下差异。是java8号还是我理解有误?
查看 DST transitions for Australia/Melbourne,由于夏令时更改,2019 年 10 月 6 日的时钟从未 02:00。这就是 DST 的工作原理:在 01:59:59.999999 之后时钟跳转到 03:00:00.000000.
这在 ZonedDateTime.of javadoc 中有记录:
In the case of a gap, when clocks jump forward, there is no valid offset. Instead, the local date-time is adjusted to be later by the length of the gap. For a typical one hour daylight savings change, the local date-time will be moved one hour later into the offset typically corresponding to "summer".
我得到夏令时开始和结束的不同结果。
ZoneId zone = ZoneId.of("Australia/Melbourne");
System.out.println(ZonedDateTime.of(2019, 04, 07, 3, 0, 0, 0, zone)); // statement-1
System.out.println(ZonedDateTime.of(2019, 10, 06, 2, 0, 0, 0, zone)); // statement-2
对于 2019 年上半年的夏令时,我得到的结果是 (2019-04-07T03:00**+10:00**[Australia/Melbourne])。 Java 正在减少 1 小时以补偿值。但是对于下半天节电 (statement-2=> 2019-10-06T03:00+11:00[Australia/Melbourne]) , java时间增加 1 小时,偏移值增加 1。
根据我的理解 java 应该增加 1 小时到时间和 +1 到偏移值(DST 结束),而 DST 开始时 java 应该从时间减少 1 小时和 1从偏移值。
请帮我澄清一下差异。是java8号还是我理解有误?
查看 DST transitions for Australia/Melbourne,由于夏令时更改,2019 年 10 月 6 日的时钟从未 02:00。这就是 DST 的工作原理:在 01:59:59.999999 之后时钟跳转到 03:00:00.000000.
这在 ZonedDateTime.of javadoc 中有记录:
In the case of a gap, when clocks jump forward, there is no valid offset. Instead, the local date-time is adjusted to be later by the length of the gap. For a typical one hour daylight savings change, the local date-time will be moved one hour later into the offset typically corresponding to "summer".