You can achieve a long UID generating a random sequence of 64bit, i.e. using AtomicLong().
AtomicLong is a long value that may be updated atomically. An
AtomicLong is used in applications such as atomically incremented
sequence numbers
private static final AtomicLong TS = new AtomicLong();
public static long getUniqueTimestamp() {
return TS.incrementAndGet();
}
Each call of getUniqueTimestamp() returns a unique id for the process, starting from 0.
You can start from an higher value initializing Atomic with current time:
private static final AtomicLong TS = new AtomicLong(System.currentTimeMillis() * 1000);
Note
this is not an UNIVERSAL UID, just a UID!