Is there a way to extract java utc time in microseconds after midnight and in 15 microseconds blocks?
Meaning that time from 1 microsecond to 15 microsecond would be represented by the same timing.
The only issue is with time resolution. In general Java supports millisecond precision via java.util.Date or System.currentTimeMillis(). If you need greater precision, System.nanoTime() might do the trick.
But this brings another issue - nanoTime() is not related to any calendar, it's just an ever growing counter with nanosecond precision. The only workaround I can think of is:
determine System.nanoTime() value at midnight, call it S. This might be problematic, but you don't have to wait until midnight, some simple math is enough.
calculate the following:
(System.nanoTime() - S) / 15000
if the value is 0, we are in the same 15-microsecond range
Are you sure JVM and your program can actually take advantage of such small timings?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With