mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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
|
@ -86,6 +86,8 @@ import java.util.Objects;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import jdk.internal.vm.annotation.Stable;
|
||||
|
||||
/**
|
||||
* A time-zone offset from Greenwich/UTC, such as {@code +02:00}.
|
||||
* <p>
|
||||
|
@ -168,6 +170,11 @@ public final class ZoneOffset
|
|||
* The string form of the time-zone offset.
|
||||
*/
|
||||
private final transient String id;
|
||||
/**
|
||||
* The zone rules for an offset will always return this offset. Cache it for efficiency.
|
||||
*/
|
||||
@Stable
|
||||
private transient ZoneRules rules;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -504,7 +511,21 @@ public final class ZoneOffset
|
|||
*/
|
||||
@Override
|
||||
public ZoneRules getRules() {
|
||||
return ZoneRules.of(this);
|
||||
ZoneRules rules = this.rules;
|
||||
if (rules == null) {
|
||||
rules = this.rules = ZoneRules.of(this);
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZoneId normalized() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package-private */ ZoneOffset getOffset(long epochSecond) {
|
||||
return this;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue