I have a table in oracle(8i) which contains a column with type DATE. If I want to insert something in this column through CMP, and I use java.sql.Timestamp for this column, it works perfectly. But if I retrieve the value of this field through CMP, it gives the Timestamp object whose format is quite different from the regular Timestamp object.
The timestamp object returned from the CMP is :
And the timestamp object created from system time, - new java.sql.Timestamp( System.currentTimeMillis() ) is
Plus, if I try to get the milliseconds from the Timestamp object returned from the CMP, it prints a large negative value.
In my application, I want to compare the timestamp object created from the current system time with the one returned from the CMP bean.
What should be the solution to this?
the java.sql.Timestamp class is not meant to be type-compatibly with
java.util.Date (even though it inherits from it it is only meant to be
considered as implementation inheritance).
So you have two solutions:
- 1 Use DateFormat or SimpleDateFormat format and parse methods to convert to the correct format but you will loose milliseconds.
- 2 use a raw(8) instead of DATE