Measure elapsed time in Nanoseconds with Java
For my recent experimental gaming project I wanted to measure the overall elapsed time since the beginning of a game.
In my main class I added a startup variable of type long which contains the current time in nanoseconds. At the end of a game call the function stopWatch(startup); to get the elapsed time in seconds.
Example: