Hi Eddie, The code that Fredrick Lindgren sent to this list looks like the right way of obtaining a java.util.Date from a java.sql.Timestamp.
As for your question of "why", part of the answer may be that three java classes are somewhat confusing: - java.util.Date (not used by JDBC) contains a date and time down to millisecond precision - java.sql.Date (used by JDBC) contains a date, and inherits from java.util.Date - java.sql.Timestamp (used by JDBC) contains a date and time down to nanosecond precision, and inherits from java.util.Date The javadoc for java.sql.Timestamp explains exactly where it stores the milliseconds (actually nanoseconds). Another question is why Sun decided to write such strange code. I'm afraid I don't have an answer for that! Nick At 10:04 AM 10/8/01 +0200, you wrote: >Thanks Frederik, > >But what I don't understand is why Date only contains the second part and >not the millisecond part and when it does ? That is, when I create a Date >object and print the millisecond part with the getTime() method, I do see >the millisecond part but when I receive something from the database, the >millisecond part is zero. Does this mean that is only zero when the date >field is handled by the JDBC part ?? > >Eddie <snip>
