It's not a secret anymore!*
The moose likes Java in General and the fly likes Convert a Timestamp to Calander Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convert a Timestamp to Calander Object" Watch "Convert a Timestamp to Calander Object" New topic
Author

Convert a Timestamp to Calander Object

Rahim Nathwani
Greenhorn

Joined: Sep 19, 2005
Posts: 19
Heyy All

I have a java.sql.Timestamp and I need to convert it to a
java.util.Calendar object.

Any ideas?

Thanks
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
If you look at the API, there is a method in TimeStamp that will convert it to a long, and a method in Date which will convert a long to a Date. Then there is a method in Calendar that will let you use the Date object.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

However since a Timestamp already is a Date, you can skip the first part.
Rahim Nathwani
Greenhorn

Joined: Sep 19, 2005
Posts: 19
Thanks

Worked!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Convert a Timestamp to Calander Object