mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8310241: OffsetDateTime compareTo redundant computation
Reviewed-by: naoto
This commit is contained in:
parent
d97966266e
commit
11fd34e196
2 changed files with 9 additions and 2 deletions
|
@ -1805,7 +1805,13 @@ public final class OffsetDateTime
|
|||
*/
|
||||
@Override
|
||||
public int compareTo(OffsetDateTime other) {
|
||||
int cmp = compareInstant(this, other);
|
||||
int cmp = getOffset().compareTo(other.getOffset());
|
||||
if (cmp != 0) {
|
||||
cmp = Long.compare(toEpochSecond(), other.toEpochSecond());
|
||||
if (cmp == 0) {
|
||||
cmp = toLocalTime().getNano() - other.toLocalTime().getNano();
|
||||
}
|
||||
}
|
||||
if (cmp == 0) {
|
||||
cmp = toLocalDateTime().compareTo(other.toLocalDateTime());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue