Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting java.sql.Date into GregorianCalendar or Calendar

 
Sajan Patel
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really wish too that there were a better way, but the only way I've done this is something like:

 
Sajan Patel
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh Yeah this will work too because upto now I was converting Date in string and showing on JSP.

thanks,
Sajan Patel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic