You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by David Sean Taylor <da...@bluesunrise.com> on 2001/10/17 19:08:01 UTC

RE: java.util.Date() into a java.sql.Date

with oracle all dates are actually timestamps, so you can use jdbc
timestamps:

java.util.Date date = new java.util.Date(); // get timestamp now
java.sql.Timestamp timeStamp = new java.sql.Timestamp(date.getTime());
ps.setTimestamp( 2, timeStamp );



> -----Original Message-----
> From: Graham.Forte@hurlburt.af.mil
> [mailto:Graham.Forte@hurlburt.af.mil]
> Sent: Wednesday, October 17, 2001 9:15 AM
> To: jetspeed-user@jakarta.apache.org
> Subject: java.util.Date() into a java.sql.Date
> Importance: Low
>
>
> Hi, I have a prepared statement that requires a date for Oracle db.
> Basically it is a field that records time and date that record was
> created(timestamp). I use this to get time and date :
> java.util.Date utilDate = new java.util.Date();
> //Now I need to convert this utilDate into a sqlDate to use
> in a prepared
> statement. I need this:  October 17, 2001 11:00:00PM which
> util gives me but
> I cant get it to sql type
> ps.setDate(2,sqlDate);
>
>
> How can I convert or better yet grab the current date/time as
> a sql.Date to
> begin with.
> THANKS!!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org