Just a simple question Can anyone tell me how to get the date and time of the system?
Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
Rene Liebmann
Ranch Hand
Joined: May 02, 2002
Posts: 196
posted
0
Hi Pete, when you initialize a Date with an empty constructor (Date date = new Date();) then it is initialized with the current Date and Time on your computer. Is this what you mean? Rene [ July 10, 2002: Message edited by: Rene Liebmann ]
Peter Phung
Ranch Hand
Joined: Dec 06, 2001
Posts: 138
posted
0
Yeah, sort of. I need to enter the date and time into a database. So i need to be able to return the date and time in a specific format i.e. if the date and time was July 10th 2002 9:45 i would need the: date : 2002-07-10 time : 09:45:00 the api isn't very clear on how to achieve this. Can you help?
Yes, SimpleDateFormat could be one solution. Another Possibility is the Calendar (GregorianCalendar). If you create a new GregorianCalendar then it already is initialized with the current time. Then the Calendar object has lots of methods to get what you want. Therefore the API has a good example. Good luck
Mahesh Mamani
Ranch Hand
Joined: Jun 25, 2001
Posts: 110
posted
0
Hi, When using the Calendar class, do take care of this functionality regd. month... Use this URL for more info MSM
Peter Phung
Ranch Hand
Joined: Dec 06, 2001
Posts: 138
posted
0
I used SimpleDateFormat because that's all i needed. Thanks to both Rene's, your help was much appreciated.