mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 14:24:46 +02:00
8283681: Improve ZonedDateTime offset handling
Reviewed-by: scolebourne, naoto, rriggs
This commit is contained in:
parent
2600f99fec
commit
7bac0a878d
5 changed files with 156 additions and 4 deletions
|
@ -452,9 +452,9 @@ public final class ZonedDateTime
|
|||
* @throws DateTimeException if the result exceeds the supported range
|
||||
*/
|
||||
private static ZonedDateTime create(long epochSecond, int nanoOfSecond, ZoneId zone) {
|
||||
ZoneRules rules = zone.getRules();
|
||||
Instant instant = Instant.ofEpochSecond(epochSecond, nanoOfSecond); // TODO: rules should be queryable by epochSeconds
|
||||
ZoneOffset offset = rules.getOffset(instant);
|
||||
// nanoOfSecond is in a range that'll not affect epochSecond, validated
|
||||
// by LocalDateTime.ofEpochSecond
|
||||
ZoneOffset offset = zone.getOffset(epochSecond);
|
||||
LocalDateTime ldt = LocalDateTime.ofEpochSecond(epochSecond, nanoOfSecond, offset);
|
||||
return new ZonedDateTime(ldt, offset, zone);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue