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
conversion problem ??
You are right that is not the JDBC driver that makes this happen. It is
JDBC itself. java.sql.Timestamp is a subclass of java.util.Date but it
returns the integral seconds when calling getTime(). It supports nano
second precision with the getNanos() method.
The javadoc
, the
millisecond part is zero. Does this mean that is only zero when the date
field is handled by the JDBC part ??
Eddie
- Original Message -
From: Fredrik Lindgren [EMAIL PROTECTED]
To: Orion-Interest [EMAIL PROTECTED]
Sent: Friday, October 05, 2001 6:50 PM
Subject: Re: Date conversion
]
Sent: Friday, October 05, 2001 6:50 PM
Subject: Re: Date conversion problem ??
You are right that is not the JDBC driver that makes this happen. It is
JDBC itself. java.sql.Timestamp is a subclass of java.util.Date but it
returns the integral seconds when calling getTime(). It supports nano
implementation inheritance, and not type inheritance.
-Original Message-
From: Sarathy Mattaparti [mailto:[EMAIL PROTECTED]]
Sent: 05 October 2001 06:33
To: Orion-Interest
Subject: Re: Date conversion problem ??
use java.util.Timestamp instead of Date that will solve your problem
You are right that is not the JDBC driver that makes this happen. It is
JDBC itself. java.sql.Timestamp is a subclass of java.util.Date but it
returns the integral seconds when calling getTime(). It supports nano
second precision with the getNanos() method.
The javadoc includes this note:
Hellu,
I retrieve a datetime field from the Ms SQL server. With a win sql client I
see:
2001-10-03 19:33:10.257
When I print the field in an EJB (I use CMP) the millisecond part is zero
!!!:
Wed Oct 03 19:33:10 GMT+02:00 2001
In milliseconds: 100213039
I had the same problem with the
use java.util.Timestamp instead of Date that will solve your problem.
Sarathy
Hellu,
I retrieve a datetime field from the Ms SQL server. With a win sql client
I
see:
2001-10-03 19:33:10.257
When I print the field in an EJB (I use CMP) the millisecond part is zero
!!!:
Wed Oct 03 19:33:10