Home arrow static arrow Java Programming [Archive] - Creating a Date from a Timestamp..
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Creating a Date from a Timestamp..
This topic has 5 replies on 1 page.

Posts:113
Registered: 5/26/04
Creating a Date from a Timestamp..  
Aug 5, 2004 12:55 PM



 
I'm getting a Timestamp instance from the DataBase and I need to create a Date.

I was using the methods timestamp.getYear(), timestamp.getMonth(), timestamp.getDay() to create a Calendar and ask the Calendar the Date but those timestamp methods are Deprecated.

How can i do it ? Some code example ?

Thanks !
 

Posts:24,036
Registered: 2/3/03
Re: Creating a Date from a Timestamp..  
Aug 5, 2004 12:57 PM (reply 1 of 5)



 
[url=http://www.javaworld.com/jw-12-2000/jw-1229-dates.html]Calculating Java dates: Take the time to learn how to create and use dates[/url]

[url=http://www.javaworld.com/javaworld/jw-03-2001/jw-0330-time.html]Working in Java time: Learn the basics of calculating elapsed time in Java[/url]

[url=http://www.javaalmanac.com/egs/java.text/FormatDate.html]Formatting a Date Using a Custom Format[/url]
[url=http://www.javaalmanac.com/egs/java.text/ParseDate.html]Parsing a Date Using a Custom Format[/url]
 

Posts:113
Registered: 5/26/04
Re: Creating a Date from a Timestamp..  
Aug 5, 2004 1:10 PM (reply 2 of 5)



 
There's no examples of Timestamp.
 

Posts:243
Registered: 3/18/04
Re: Creating a Date from a Timestamp..  
Aug 5, 2004 1:13 PM (reply 3 of 5)



 
Uhh, look at Timestamp's getTime() method, that's all you need.
 

Posts:31,095
Registered: 4/30/99
Re: Creating a Date from a Timestamp..  
Aug 5, 2004 1:24 PM (reply 4 of 5)



 
You don't even need that. Timestamp is a subclass of Date so you can use it anywhere a Date can be used.
 

Posts:113
Registered: 5/26/04
Re: Creating a Date from a Timestamp..  
Aug 5, 2004 1:41 PM (reply 5 of 5)



 
yea It's done. Thanks all.
 
This topic has 5 replies on 1 page.