Java Minute calculateRuntimeMinutes(long startTime, long endTime)

Here you can find the source of calculateRuntimeMinutes(long startTime, long endTime)

Description

calculate Runtime Minutes

License

Open Source License

Declaration

public static String calculateRuntimeMinutes(long startTime, long endTime) 

Method Source Code

//package com.java2s;
/*/* w ww.  j  av  a  2 s . c om*/
Copyright (C) 2011  Diego Darriba, David Posada
    
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

public class Main {
    public static String calculateRuntimeMinutes(long startTime, long endTime) {
        long seconds = Math.round((endTime - startTime) / 1000.0);
        int hours = (int) (seconds / 3600.0);
        int rest1 = (int) (seconds % (3600.0));
        int minutes = (int) (rest1 / 60.0);
        seconds = (int) (seconds - (hours * 3600 + minutes * 60));
        String h = "" + hours;
        String m = "" + minutes;
        String s = "" + seconds;
        if (minutes < 10)
            m = "0" + m;
        if (seconds < 10)
            s = "0" + s;
        return h + "h:" + m + ":" + s + "";
    }
}

Related

  1. addMinutesToMjd(double mjd, double minutes)
  2. buildDelayParamForMinutes(final int delayInMinutes)
  3. calMinutes(Date date1, Date date2)
  4. countMinute(Long time)
  5. elapsedMinutes(int beginTimeInMinutes, int endTimeInMinutes)
  6. extractMinutes(String[] parts)