=maximus= wrote:
> Hi Thomas. Here is my code.
>
> CREATE TABLE TEST(... DATE_VIEWED DATE DEFAULT NULL, ...)
>
> For date types conversion I use:
>
> public static java.util.Date convertSqlToUtilDate( final java.sql.Date
> in_SqlDate ){
>   return ( null != in_SqlDate ) ? new java.util.Date
> ( in_SqlDate.getTime() ) : null;
> }
>
> public static java.sql.Date convertUtilToSqlDate( final java.util.Date
> in_UtilDate ){
>   return ( null != in_UtilDate ) ? new java.sql.Date
> ( in_UtilDate.getTime() ) : null;
> }
>
>
> Please tell me, why when I write new java.util.Date() object into the
> column and then
> read it these two dates are not equal? Could I just store a Long
> (milliseconds)?
>
> Thank you.
> P.S. I'm new in databases and SQL.
> Maxim.
>   

Hi Maximus,

Could you show us the code you use to read and write data from the 
database. ie. A small class, with no dependencies that clearly 
demonstrates the problem. Also, how are you testing for equality? 
correct way would be date1.equals(date2) or even date1.getTime() == 
date2.getTime();

Also, java.sql.Date extends java.util.Date, and only overrides 
toString() and little else... are you sure you need to convert between 
them? Maybe just use the java.sql.Date as a java.util.Date?

Cheers,
Jesse

--

You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.


Reply via email to