public long nextKey ( ) { // Note that per Oracle the currentTimeMillis is the current number of seconds past the epoch // in UTC (not in local time). Therefore, processes with exactly synchronized clocks will // always get the same value regardless of their timezone ... final long timestamp = System . currentTimeMillis ( ) ; final int increment = counterFor ( timestamp ) ; if ( increment <= maximumCounterValue ) { return ( timestamp << counterBits ) + increment ; } // The counter is surprisingly too high, so try again (repeatedly) until we get to the next millisecond ... return this . nextKey ( ) ; }
Get the next key for the current time in UTC .