android - subtract minutes or hours from calculated time -


i calculating time between 2 given dates. , saving lunch time can 1 hour , 45 minutes or more. lunch time saving hours in 1 variable , minutes in another.

let's worked time 11 hours , 0 minutes , lunch break 1 hour , 45 minutes. how subtract worked time 11 hour 9 hours , 15 minutes in case.

try :

int worktimehours = 11; int worktimeminutes = 0; int worktimesecs = 10; int time1 =  worktimehours*3600 + worktimeminutes*60+ worktimesecs;  int breaktimehours = 1; int breaktimeminutes = 45; int breaktimesecs = 11; int time2 = breaktimehours*3600 + breaktimeminutes*60+ breaktimesecs;  int timediff = time1 - time2; 

this give time difference(timediff) in seconds can hours, minutes , secs!


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -