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
If you have Spring as a dependency of your project (or don't mind adding it), you can use StopWatch. As the name suggests, once initialized it will count the time until you stop it. You can then check the time taken for a task. Multiple StopWatches can be used simultaneously to multiple tasks keeping the code clean.
Besides keeping your code clean, StopWatches help with formatting the time and other utility methods.
public void myMethod(){
StopWatch stopWatch = new StopWatch();
stopWatch.start("Task1");
// ...
// Do my thing
// ...
stopWatch.stop();
System.out.println("Task executed in " + stopWatch.getTotalTimeSeconds() + "s");
}