Patch: FYI: java.sql update
Tom Tromey
tromey@redhat.com
Mon Feb 10 19:54:00 GMT 2003
Inspired by Erik Poupaert, I looked at our java.sql comparison.
It turns out we were just a couple methods away from 100% conformance,
so I wrote this patch.
This is going in 3.3, 3.4, and Classpath.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* java/sql/Timestamp.java (compareTo(Object)): New method.
(compareTo(Timestamp)): Likewise.
(serialVersionUID): Updated.
Index: java/sql/Timestamp.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/sql/Timestamp.java,v
retrieving revision 1.6
diff -u -r1.6 Timestamp.java
--- java/sql/Timestamp.java 21 Jun 2002 05:34:12 -0000 1.6
+++ java/sql/Timestamp.java 10 Feb 2003 19:41:09 -0000
@@ -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 @@
*/
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 @@
}
/**
+ * 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);
- }*/
+ }
}
More information about the Java-patches
mailing list