my dog learned polymorphism*
The moose likes Java in General and the fly likes converting java.sql.Date into GregorianCalendar or Calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting java.sql.Date into GregorianCalendar or Calendar" Watch "converting java.sql.Date into GregorianCalendar or Calendar" New topic
Author

converting java.sql.Date into GregorianCalendar or Calendar

Sajan Patel
Ranch Hand

Joined: Oct 25, 2004
Posts: 77
Hi
Below steps are in different file
1)
Created GregorianCalaendar(yearInt, monthInt, dateInt)

2)for storing in database as a datetime (in SQL server)
convert it in to java.sql.date
psmnt2.setDate(3,new java.sql.Date(gregCale.getTime().getTime()));/*which return long date and then new object of sql.Date*/

Now I am trying to get that date back from database. Right now I am using ResultSet for that and it is giving me nack Date object.

so could anyone tell me how to convert Date to GregorianCalendar object in java 1.4 or is there any other way I can store date in any format and get date back in any other format.

Thanks
Sajan Patel
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
I really wish too that there were a better way, but the only way I've done this is something like:



<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
Sajan Patel
Ranch Hand

Joined: Oct 25, 2004
Posts: 77
Ohh Yeah this will work too because upto now I was converting Date in string and showing on JSP.

thanks,
Sajan Patel
 
 
subject: converting java.sql.Date into GregorianCalendar or Calendar