/** * Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to * generate sequential UUIDs for the same period in time. I.E * <p/> * newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br /> * <p/> * etc. * <p/> * Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp * offset * * @param ts The timestamp in milliseconds * @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will * be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored * in the time uuid. */ public static UUID newTimeUUID( long ts, int timeoffset ) { if ( ts == 0 ) { return newTimeUUID(); } byte[] uuidBytes = new byte[16]; // 47 bits of randomness EthernetAddress eth = EthernetAddress.constructMulticastAddress(); eth.toByteArray( uuidBytes, 10 ); setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset ); return uuid( uuidBytes ); }