Class Deadline


  • public class Deadline
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Deadline()
      No need to use this constructor, use static methods instead.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long getDeadline​(long timeout)
      Calculate the epoch timestamp when a timeout will expire.
      • Methods inherited from class java.lang.Object

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

      • Deadline

        public Deadline()
        No need to use this constructor, use static methods instead.
    • Method Detail

      • getDeadline

        public static long getDeadline​(long timeout)
        Calculate the epoch timestamp when a timeout will expire. This deadline is computed by adding the timeout to System.currentTimeMillis(). This computation is protected against overflow, that is, the deadline will never exceed Long.MAX_VALUE. This allows the user to simply test if the deadline has passed by performing a check against the current epoch time: if (deadline <= System.currentTimeMillis()) { // deadline has passed }
        Parameters:
        timeout - the timeout to compute the deadline with. Must be >= 0 or an IllegalArgumentException will be thrown.
        Returns:
        the timestamp at which the timeout will expire, or Long.MAX_VALUE if the timeout causes an overflow.