Tuesday, November 25, 2003

I was just reading the javadoc for Timestamp (which is a subclass of date). It has a disclaimer that's kind of entertaining:

"The Timestamp.equals(Object) method never returns true when passed a value of type java.util.Date because the nanos component of a date is unknown. As a result, the Timestamp.equals(Object) method is not symmetric with respect to the java.util.Date.equals(Object) method. Also, the hashcode method uses the underlying java.util.Data implementation and therefore does not include nanos in its computation. Due to the differences between the Timestamp class and the java.util.Date class mentioned above, it is recommended that code not view Timestamp values generically as an instance of java.util.Date. The inheritance relationship between Timestamp and java.util.Date really denotes implementation inheritance, and not type inheritance."


"We really shouldn't have inherited from date, but we did anyway because favoring inheritance over composition has always worked for us in the past (isn't Swing swell, after all). We decided this was a good thing because - hey - we already wrote the code, and it's working. Besides, it's not really a problem if we document it, right?"



Post a Comment

Subscribe to Post Comments [Atom]

<< Home