An easy to use library for formatting human readable time differences in many languages.
You can try it for yourself:
import gbc.jtimecalc.TimeDifferenceCalculator;
public class SimpleExample {
public static void main(String[] args) {
System.out.println("1. Starting operation");
long startTime = System.currentTimeMillis();
System.out.println("2. Invoking some time consuming method");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("3. Finishing operation");
long endTime = System.currentTimeMillis();
System.out.println("Result:");
for (TimeDifferenceCalculator calc : TimeDifferenceCalculator.values()) {
System.out.println(calc + ": "
+ calc.getTimeDifferenceAsString(endTime, startTime)
+ " , type: " + calc.getType());
}
}
}
The jtimecalc library is licensed under MIT license.