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"
Joined: May 02, 2002
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 ]
Joined: Dec 06, 2001
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