java - Calculating the time difference with seconds -


here have got code part counts difference between 2 times(time1,time2). how can add seconds , convert 60sec 1 minute?

i assume there simpler way deal it, studying book beginners i'd answer in same way hours , minutes calculated here.

  hours=time2/100-time1/100;   mins=time2%100-time1%100;    hours=mins>0?hours:hours-1;   mins=mins>0?mins:mins+60; 

 simpledateformat sdf = new simpledateformat("hh:mm:ss");         long starttime = sdf.parse("10:00:00").gettime();         long endtime = sdf.parse("11:00:00").gettime();         long duration = endtime - starttime;          int seconds = (int) (duration / 1000) % 60;         int minutes = (int) ((duration / (1000 * 60)) % 60);         int hours = (int) ((duration / (1000 * 60 * 60)) % 24); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -