I have to generate a unique Id which is readable as well hence cannot use UUID. So I thought of using Instant.toEpochMilli(). Can it be used as unique id?
No. I personally faced with situation, when two objects had same id. I have tested System.nanoTime()
and it looked OK, but in general case both variants are not correct.
Correct solutions:
UUID.randomUUID()
AtomicLong