This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to convert MS SQL DateTime into Java Date? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "How to convert MS SQL DateTime into Java Date?" Watch "How to convert MS SQL DateTime into Java Date?" New topic
Author

How to convert MS SQL DateTime into Java Date?

Ravi Sathish
Ranch Hand

Joined: Feb 26, 2002
Posts: 131
Hi
I am not able to figure how to conevert a MS SQL 2000 DateTime to Java format viz. date, time or Time stamp?
I am trying to retrive from database using resultset
I tired string, object etc
any help will be appreciated
Thanks
Ravi
Marie Mazerolle
Ranch Hand

Joined: Oct 01, 2002
Posts: 81
I'm sure there's a better solution than this, but in your query, you could select YEAR(theDate), MONTH(theDate) and DAY(theDate). Then, construct a java date from these values.
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
ResultSet.getDate(index) should return a java.sql.Date. Dint this work for you?
reg.
[ December 02, 2003: Message edited by: shankar vembu ]
Ravi Sathish
Ranch Hand

Joined: Feb 26, 2002
Posts: 131
Thanks Marie
That one works cool. Is there a way to extract the time similarly?
Ravi
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to convert MS SQL DateTime into Java Date?
 
Similar Threads
java sql TYPE
Servlet and JDBC error
Passing Date in Callable Statement
how to change the date,Time format after accessing it from the database
string to date conversion