I have a Java application that I\'ve been working on and I just realized that the program has to return a value in less than a minute, but don\'t know how to find or display
I like using the Apache Commons StopWatch class when I have the library available.
import org.apache.commons.lang3.time.StopWatch;
// ...
StopWatch stopWatch = new StopWatch();
String message = "Task : %s (%s) seconds";
// ...
stopWatch.split();
System.out.println(String.format(message, "10", stopWatch.toSplitString()));
// ...
stopWatch.split();
System.out.println(String.format(message, "20", stopWatch.toSplitString()));
stopWatch.stop();