A DESCRIPTION OF THE PROBLEM :
this is a code which works in java 1.5.0_12
but NOT in java 1.5.0_04 (ClassCastException)
public static void main(String[] args) {
Date date = new Date();
Date ts = new Timestamp(date.getTime());
System.out.println(ts.compareTo(date));
}
This behaviour broke compatibility to 1.4 and you corrected this in 1.5.0_12, but you forgot to change the documentation:
If the argument is not a Timestamp object, this method throws a ClassCastException object. (Timestamp objects are comparable only to other Timestamp objects.) this is not true anymore
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
just say that now it works with any Date
ACTUAL -
If the argument is not a Timestamp object, this method throws a ClassCastException object. (Timestamp objects are comparable only to other Timestamp objects.) this is not true anymore
URL OF FAULTY DOCUMENTATION :
http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html#compareTo(java.util.Date)
this is a code which works in java 1.5.0_12
but NOT in java 1.5.0_04 (ClassCastException)
public static void main(String[] args) {
Date date = new Date();
Date ts = new Timestamp(date.getTime());
System.out.println(ts.compareTo(date));
}
This behaviour broke compatibility to 1.4 and you corrected this in 1.5.0_12, but you forgot to change the documentation:
If the argument is not a Timestamp object, this method throws a ClassCastException object. (Timestamp objects are comparable only to other Timestamp objects.) this is not true anymore
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
just say that now it works with any Date
ACTUAL -
If the argument is not a Timestamp object, this method throws a ClassCastException object. (Timestamp objects are comparable only to other Timestamp objects.) this is not true anymore
URL OF FAULTY DOCUMENTATION :
http://java.sun.com/javase/6/docs/api/java/sql/Timestamp.html#compareTo(java.util.Date)