diff options
author | Tom Tromey <tromey@redhat.com> | 2003-02-10 19:56:12 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-02-10 19:56:12 +0000 |
commit | 848f2ce8d5c3c0d124ece9955122418bba9e5d55 (patch) | |
tree | a4125fe7fb419c85e29a2ed76bc35d14fd1e2886 /libjava/java | |
parent | aa634f11e65d7630b96742a4f3d187d920e0c87e (diff) | |
download | gcc-848f2ce8d5c3c0d124ece9955122418bba9e5d55.zip gcc-848f2ce8d5c3c0d124ece9955122418bba9e5d55.tar.gz gcc-848f2ce8d5c3c0d124ece9955122418bba9e5d55.tar.bz2 |
Timestamp.java (compareTo(Object)): New method.
* java/sql/Timestamp.java (compareTo(Object)): New method.
(compareTo(Timestamp)): Likewise.
(serialVersionUID): Updated.
From-SVN: r62648
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/sql/Timestamp.java | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/libjava/java/sql/Timestamp.java b/libjava/java/sql/Timestamp.java index c42ff3c..0f8b44c 100644 --- a/libjava/java/sql/Timestamp.java +++ b/libjava/java/sql/Timestamp.java @@ -1,5 +1,5 @@ /* Time.java -- Wrapper around java.util.Date - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -52,7 +52,7 @@ import java.text.SimpleDateFormat; */ public class Timestamp extends java.util.Date { - static final long serialVersionUID = 3581463369166924961L; + static final long serialVersionUID = 2745179027874758501L; /** * Used for parsing and formatting this date. @@ -237,19 +237,37 @@ public class Timestamp extends java.util.Date } /** + * Compare two Timestamp + * @param when the other Timestamp. + * @return 0, if the date represented + * by obj is exactly the same as the time represented by this + * object, a negative if this Timestamp is before the other Timestamp, and + * a positive value otherwise. * @since 1.2 */ - /* public int compareTo(Timestamp ts) { - - }*/ - + int s = super.compareTo((java.util.Date) ts); + if (s != 0) + return s; + // If Date components were equal, then we check the nanoseconds. + return nanos - ts.nanos; + } + /** + * Compares this Timestamp to another. This behaves like + * <code>compareTo(Timestamp)</code>, but it may throw a + * <code>ClassCastException</code> + * @param obj the other Timestamp. + * @return 0, if the Timestamp represented + * by obj is exactly the same as the time represented by this + * object, a negative if this Timestamp is before the other Timestamp, and + * a positive value otherwise. + * @exception ClassCastException if obj is not of type Timestamp. * @since 1.2 - *//* + */ public int compareTo(Object obj) { return compareTo((Timestamp) obj); - }*/ + } } |