0

I have these two times

2011-9-5 0:00
2011-9-5 15:50

when i get there time difference by

Date d1=df.parse(interviewList.get(28).getTime());
Date d2=df.parse(interviewList.get(29).getTime());
long d1Ms=d1.getTime();
long d2Ms=d2.getTime();
diff =  Math.abs((d1Ms-d2Ms)/60000);

it gives me correct difference but the difference coming is 950
How can i get it in a proper format like 15:50 ( which is the diff of above two)

Thanks

jmj
  • 237,923
  • 42
  • 401
  • 438
junaidp
  • 10,801
  • 29
  • 89
  • 137
  • Possible duplicate to http://stackoverflow.com/questions/5387371/how-to-convert-minutes-to-hours-and-minutes-hhmm-in-java – juergen d Jan 26 '12 at 07:35

1 Answers1

3

It gives you correct difference,

950 minute = 15 hour and 50 min

you can achieve this by

int hour = totalMinutes / 60;
int minute = totalMinutes - (hour * 60);

and then

String dispString = hour + ":" + minute;
jmj
  • 237,923
  • 42
  • 401
  • 438