dcsimg
getting the current date and time
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sachu_mexon
Posted On:   Tuesday, June 18, 2002 10:53 AM

can anyone tell me how to do this.


what i want to do is:


i want to get the current date and time


for eg: i want to have


061820021:46:42

stored to a string datetime. so that each time i display datetime , i get the current date and time.
here it is

mmddyyyyhh:mm:ss


thankyou

Re: getting the current date and time

Posted By:   Rob_Eamon  
Posted On:   Wednesday, August 28, 2002 08:35 PM

It's quite trivial.
java.util.Date now = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("MMddyyyy:mm:ss");
String datetimeStr = sdf.format(now);

Note that in the format string, letter case is very important (i.e. MM is month, mm is minutes).

Re: getting the current date and time

Posted By:   Scott_Yaung  
Posted On:   Sunday, July 21, 2002 01:31 PM

build ur own class, using java.text.SimpleDateFormat and java.util.Date
About | Sitemap | Contact