I have two times in an array, and I need to calculate the difference between them. I converted the hours to minutes, then added the remaining minutes. It gives me total minutes in general, as soon as I did it for both, I just minus one total minute from the other. Then they were converted back to hours and minutes.
double no1 = Double.parseDouble(array[i][4]);
int time1_calc = (int) (no1 * 100); //Remove decimal point
int time1hours = (time1_calc) / 100;
int time1mins = (time1_calc) % 100;
int time1HM = time1hours*60;
int time1_total = time1HM + time1mins;
The above code is used a second time, then I use:
int total = time2_total - time1_total;
To do this, all calculations "look" at the work, but, for example, the difference between 10.18 and 09.35 is 1 hour 23 minutes or 83 minutes. It seems my program shows 43 minutes.
I tried other ways, but still can't get it to work, any ideas?
Thanks =)
source
share