Java Reaction Time Test - Time Elapsed?
date, java, system
Solution
`System.nanoTime()` is the best way to get definite precision.
See: System.nanoTime():
`Returns the current value of the most precise available system timer, in nanoseconds.`
Problem
I am trying to make a very simple reaction time test program. It consists of a button "Begin Test" and a button "Click Me". After the first button is pressed, the second one flashes red after some random seconds. Time is calculated by the time it's turned red and pressed by the user. As far as I've searched, there are 3 ways to calculate the program elapsed / execution time in milliseconds: - Date().getTime() - System.currentTimeMillis() - System.nanoTime() Which one would be more suitable for me? Truth is I need definite precision in my timing. Thanks a lot :)