Class Timestamper


  • public final class Timestamper
    extends java.lang.Object
    Generates increasing identifiers (in a single VM only). Not valid across multiple VMs. Yet, the identifier is based on time, so that the drifting across a cluster should not ever be large...
    Author:
    Alex Snaps
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BIN_DIGITS
      Value for left shifting System.currentTimeMillis, freeing some space for the counter
      static int ONE_MS
      What is one milliseconds, based on "counter value reserved space", for this Timestamper
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long next()
      Returns an increasing unique value based on the System.currentTimeMillis() with some additional reserved space for a counter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • BIN_DIGITS

        public static final int BIN_DIGITS
        Value for left shifting System.currentTimeMillis, freeing some space for the counter
      • ONE_MS

        public static final int ONE_MS
        What is one milliseconds, based on "counter value reserved space", for this Timestamper
    • Method Detail

      • next

        public static long next()
        Returns an increasing unique value based on the System.currentTimeMillis() with some additional reserved space for a counter.
        Returns:
        uniquely & increasing value
        See Also:
        BIN_DIGITS