What is the best way to get a program to display the correct time in the output? I am using java.util.Calendar, but at 12:24:40 it is displaying 0244. How do I correct this, or what is a better way to show the time? Thanks Robin
Shama Khan
Ranch Hand
Joined: Aug 14, 2000
Posts: 185
posted
0
Not a direct answer but ...
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd G 'at' hh:mm:ss a zzz"); Date currentTime_1 = new Date(); String dateString = formatter.format(currentTime_1);
// Parse the previous string back into a Date. ParsePosition pos = new ParsePosition(0); Date currentTime_2 = formatter.parse(dateString, pos); System.out.println(currentTime_2);