mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8277868: Use Comparable.compare() instead of surrogate code
Reviewed-by: rriggs, aivanov
This commit is contained in:
parent
937126b140
commit
20db7800a6
12 changed files with 23 additions and 75 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,18 +26,13 @@
|
|||
package java.util;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.time.Instant;
|
||||
import sun.util.calendar.BaseCalendar;
|
||||
import sun.util.calendar.CalendarDate;
|
||||
import sun.util.calendar.CalendarSystem;
|
||||
import sun.util.calendar.CalendarUtils;
|
||||
import sun.util.calendar.Era;
|
||||
import sun.util.calendar.Gregorian;
|
||||
import sun.util.calendar.ZoneInfo;
|
||||
|
||||
/**
|
||||
|
@ -975,10 +970,9 @@ public class Date
|
|||
* @since 1.2
|
||||
* @throws NullPointerException if {@code anotherDate} is null.
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Date anotherDate) {
|
||||
long thisTime = getMillisOf(this);
|
||||
long anotherTime = getMillisOf(anotherDate);
|
||||
return (thisTime<anotherTime ? -1 : (thisTime==anotherTime ? 0 : 1));
|
||||
return Long.compare(getMillisOf(this), getMillisOf(anotherDate));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue