Java gives access to two method to get the current time: System.nanoTime()
and System.currentTimeMillis()
. The first one gives a result in nanoseconds,
If you are looking to record some type of phenomenon on the order of nanoseconds, what you really need is a real-time operating system. The accuracy of the timer will greatly depend on the operating system's implementation of its high resolution timer and the underlying hardware.
However, you can still stay with Java since there are RTOS versions available.