How to display in HH:MM:SS... ?
I am having two dates with times for example:
String dateStart = "01/14/2012 09:30:55";
String dateStop = "01/15/2012 18:25:54";
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date d1 = null;
Date d2 = null;
d1 = format.parse(dateStart);
d2 = format.parse(dateStop);
When I subtract: d2 - d1, I want to show the elapsed time in between the above two dates in the format of HH:MM:SS:
I want the output something like:
33:05:01. How can I get in that format..? If anybody is having any idea please help me out...
Re: How to display in HH:MM:SS... ?
Well, I am not certain you can use the HH format because it seems to format modulo 24. So at present, all I can recommend is that you subtract the long values returned by Data.getTime() and compute the hours, mins, and seconds yourself. Remember that getTime returns millisecond granularity. You can use System.printf() to format them yourself. Perhaps someone else on this forum can provide better advice.