public final class LongUtils
extends java.lang.Object
Modifier and Type | Method and 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. |
public static long safeAdd(long a, long b)
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 com.google.common.math.LongMath#checkedAdd(long, long)
that returns Long.MAX_VALUE
instead of throwing ArithmeticException
.com.google.common.math.LongMath#checkedAdd(long, long)
public static long calculateExpirationTime(long expiration)
new Date().getTime()
and
the specified expiration
in number of milliseconds.expiration
- The expiration in milliseconds.Copyright © 2010 - 2020 Adobe. All Rights Reserved