I want to mark time stamps in messages as they flow from one JVM to another running on different hosts. Understand that System.nanoTime() is relative to JVM start time. Hence do not make it useful for this use case. Is Java Instant the solution?
Asked
Active
Viewed 36 times
0
-
3What are your requirements and constraints? Why is `System.currentTimeMillis()` not good enough? – knittl Jul 13 '21 at 18:11
-
3Depending on your exact use case, you may need something much, much more complicated, as "time stamps flowing between hosts" is a [fundamental and hard problem](https://en.wikipedia.org/wiki/Lamport_timestamp?wprov=sfla1) in distributed systems. Is this just for logging, or do you actually depend on "if message B was sent as a result of message A, then B must have a timestamp after A"? – Louis Wasserman Jul 13 '21 at 18:28
-
@knittl The reason is the min latency is in micros. – The Roy Jul 14 '21 at 03:37
-
@TheRoy latency of what? Time it takes to send and receive messages? I think you are out of luck. Clock skew between different hosts with synchronized clocks (e.g. NTP) is usually in the tens of _milliseconds_. – knittl Jul 14 '21 at 05:58