richardsimnett
asked on
getting todays date as mm/dd/yyyy hh:mm:ss
Hello,
Can anyone tell me how to get a string which is todays date and time in the format of mm/dd/yyyy hh:mm:ss?
Worth 500 points.
Thanks,
Rick
Can anyone tell me how to get a string which is todays date and time in the format of mm/dd/yyyy hh:mm:ss?
Worth 500 points.
Thanks,
Rick
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy yy hh:mm:ss a");
String today = sdf.format(new Date());
// HH => 0 to 23 ; hh => 1 to 12 ; a => AM or PM
http://javaalmanac.com/egs/java.text/FormatDate.html
http://javaalmanac.com/egs/java.text/FormatTime.html
String today = sdf.format(new Date());
// HH => 0 to 23 ; hh => 1 to 12 ; a => AM or PM
http://javaalmanac.com/egs/java.text/FormatDate.html
http://javaalmanac.com/egs/java.text/FormatTime.html
ASKER
lbdkutty,
what package do I need to import for that code to complile properly?
Thanks,
Rick
what package do I need to import for that code to complile properly?
Thanks,
Rick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works great.
Thanks,
Rick
Thanks,
Rick
String today = sdf.format(new Date());
System.out.println(today);