Get elapsed time in days in Java
Description
The following code shows how to get elapsed time in days.
Example
/*from www .j a v a 2 s . co 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;
float elapsedTimeDay = elapsedTimeMillis/(24*60*60*1000F);
System.out.println(elapsedTimeDay);
}
}
The code above generates the following result.