Into a batch Java application (an application that run into the console) I have to log how long it takes to perform a specific task (some operations as a query execution).
So I am thinking that to do it I can retrive the date and time before my task begin and take it again after that the task is completed, then subtract the first value form the second one and use log4j to print the result into a log file.
But, if it is a good solution is correct, how can I correctly take this value (date and time)?
Exist some smarter way to do it?