Class LongUtils


  • public final class LongUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static long calculateExpirationTime​(long expiration)
      Calculate an expiration time based on new Date().getTime() and the specified expiration in number of milliseconds.
      static long safeAdd​(long a, long b)
      Sums a and b and verifies that it doesn't overflow in signed long arithmetic, in which case Long.MAX_VALUE will be returned instead of the result.
      • Methods inherited from class java.lang.Object

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

      • safeAdd

        public static long safeAdd​(long a,
                                   long b)
        Sums a and b and verifies that it doesn't overflow in signed long arithmetic, in which case Long.MAX_VALUE will be returned instead of the result. Note: this method is a variant of LongMath.checkedAdd(long, long) that returns Long.MAX_VALUE instead of throwing ArithmeticException.
        See Also:
        LongMath.checkedAdd(long, long)
      • calculateExpirationTime

        public static long calculateExpirationTime​(long expiration)
        Calculate an expiration time based on new Date().getTime() and the specified expiration in number of milliseconds.
        Parameters:
        expiration - The expiration in milliseconds.
        Returns:
        The expiration time.