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 Gr...@hurlburt.af.mil on 2001/10/17 18:14:47 UTC
java.util.Date() into a java.sql.Date
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
Re: java.util.Date() into a java.sql.Date
Posted by Santiago Gala <sg...@hisitech.com>.
Graham.Forte@hurlburt.af.mil wrote:
>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!!
>
http://java.sun.com/products/jdk/1.2/docs/api/java/util/Date.html#getTime()
http://java.sun.com/products/jdk/1.2/docs/api/java/sql/Date.html#Date(long)
>
>
>
>---------------------------------------------------------------------
>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
AW: java.util.Date() into a java.sql.Date
Posted by Norman Schöneich <sc...@ecooperate.de>.
I would use a timestamp instead of sql date.
ps.setTimestamp(2, new Timestamp(utilDate.getTime());
if you prefer sql date, it's analog.
the current time is : new
Timestamp(Calendar.getInstance().getTime().getTime());
norsch
Norman Schöneich
-----Ursprüngliche Nachricht-----
Von: Graham.Forte@hurlburt.af.mil [mailto:Graham.Forte@hurlburt.af.mil]
Gesendet: Mittwoch, 17. Oktober 2001 18:15
An: jetspeed-user@jakarta.apache.org
Betreff: java.util.Date() into a java.sql.Date
Wichtigkeit: Niedrig
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
RE: java.util.Date() into a java.sql.Date
Posted by David Sean Taylor <da...@bluesunrise.com>.
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