Get elapsed time in minutes in Java
Description
The following code shows how to get elapsed time in minutes.
Example
/*w w w . j a v a2 s . c o m*/
public class Main {
public static void main(String[] argv) throws Exception {
long start = System.currentTimeMillis();
Thread.sleep(2000);
// Get elapsed time in milliseconds
long elapsedTimeMillis = System.currentTimeMillis() - start;
// Get elapsed time in minutes
float elapsedTimeMin = elapsedTimeMillis/(60*1000F);
System.out.println(elapsedTimeMin);
}
}
The code above generates the following result.