Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert MS SQL DateTime into Java Date?

 
Ravi Sathish
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marie
That one works cool. Is there a way to extract the time similarly?
Ravi
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!