Here you can find the source of calculateRuntime(long startTime, long endTime)
public static String calculateRuntime(long startTime, long endTime)
//package com.java2s; //License from project: Apache License import java.util.concurrent.TimeUnit; public class Main { public static String calculateRuntime(long startTime, long endTime) { long runTime = endTime - startTime; long minutes = TimeUnit.MILLISECONDS.toMinutes(runTime); runTime -= TimeUnit.MINUTES.toMillis(minutes); long seconds = TimeUnit.MILLISECONDS.toSeconds(runTime); runTime -= TimeUnit.SECONDS.toMillis(seconds); long millis = runTime; String runTimeStr = String.format("%d min, %d sec, %d ms", minutes, seconds, millis);/* www .ja va2s.c om*/ return runTimeStr; } }