This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes How do I convert a Timestamp to a Calendar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do I convert a Timestamp to a Calendar?" Watch "How do I convert a Timestamp to a Calendar?" New topic
Author

How do I convert a Timestamp to a Calendar?

keith tyson
Greenhorn

Joined: Sep 28, 2001
Posts: 7
I have a method that returns a Timestamp and I need to pass this to a method that is expecting a Calendar object.
ie.
deliveryDetails.getWindowStart() // returns a Timestamp
and I need to pass another method this value as a Calendar.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Keith,
Since Timestamp is a subclass of Date, the following should work:
GregorianCalendar gc = new GregorianCalendar();
gc.setTime( deliveryDetails.getWindowStart() );
newMethod( gc );
Regards,
Manfred.
 
 
subject: How do I convert a Timestamp to a Calendar?