private static long getUUIDTime ( ) { if ( _currentMillis != System . currentTimeMillis ( ) ) { _currentMillis = System . currentTimeMillis ( ) ; _counter = 0 ; // reset counter } // check to see if we have created too many uuid's for this timestamp if ( _counter + 1 >= MILLI_MULT ) { // Original algorithm threw exception. Seemed like overkill. // Let's just increment the timestamp instead and start over... _currentMillis ++ ; _counter = 0 ; } // calculate time as current millis plus offset times 100 ns ticks long currentTime = ( _currentMillis + GREG_OFFSET ) * MILLI_MULT ; // return the uuid time plus the artificial tick counter incremented return currentTime + _counter ++ ; }
Gets the appropriately modified timestamep for the UUID . Must be called from a synchronized block .