I know this can be done in Linux, through a native call to clock_gettime
from sys/time.h
.
I know this can be done with System.currentTimeMillis() * 1000000L
, which is not good because you can have two equal epoch times if you call that in succession.
Wondering if in the more recent versions of Java there is already a Java way of getting Epoch in nanoseconds.
NOTE: I want the epoch with nanosecond precision. I just don't want to convert it to milliseconds with something like:
long nanos = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis());
Thanks for any help!
EDIT1: I'm not worried about getting the same epoch time twice. My goal is to have a real epoch time in nanoseconds.