amethystct
Programmer
I'm getting the milli from 2 dates, current & a passed date. I want to know the difference in time down to the second between the 2 dates.
Given this date: 2004-02-05 18:25:00
and current of 2004-02-17 09:40:00
I get a time difference of 27:166:100. This is supposed to be hours min seconds.
This is how I'm calculating it:
long compare1Milli = compare1.getTime().getTime();
long compare2Milli = compare2.getTime().getTime();
// 1000 mil/sec
// 60 sec/min
//60 min/hour
//24 hour/day
long diffMillis = compare1Milli - compare2Milli;
long diffDays = diffMillis/
(24 * 60 * 60 * 1000);
long diffSecs = diffMillis/(1000);
// Get difference in minutes
long diffMins = diffMillis/(60*1000);
// Get difference in hours
long diffHours = diffMillis/(60*60*1000);
returnDifference = new Long(diffHours).toString() + ":" +
new Long(diffMins).toString() + ":" + new Long(diffSecs).toString();
Given this date: 2004-02-05 18:25:00
and current of 2004-02-17 09:40:00
I get a time difference of 27:166:100. This is supposed to be hours min seconds.
This is how I'm calculating it:
long compare1Milli = compare1.getTime().getTime();
long compare2Milli = compare2.getTime().getTime();
// 1000 mil/sec
// 60 sec/min
//60 min/hour
//24 hour/day
long diffMillis = compare1Milli - compare2Milli;
long diffDays = diffMillis/
(24 * 60 * 60 * 1000);
long diffSecs = diffMillis/(1000);
// Get difference in minutes
long diffMins = diffMillis/(60*1000);
// Get difference in hours
long diffHours = diffMillis/(60*60*1000);
returnDifference = new Long(diffHours).toString() + ":" +
new Long(diffMins).toString() + ":" + new Long(diffSecs).toString();