Class Instants
java.lang.Object
org.apache.commons.lang3.time.Instants
-
Method Summary
Modifier and TypeMethodDescriptionstatic longtoEpochMillis(Instant instant) Converts an Instant to milliseconds bound to alongwithout throwingArithmeticException.static InstantReturns the given non-null instant, orInstant.EPOCHif null.static InstantReturns the given non-null instant, ordefaultInstantif instant is null.static longtoMillisSince(Instant instant) Converts an Instant to milliseconds since that Instant bound to alongwithout throwingArithmeticException.
-
Method Details
-
toEpochMillis
Converts an Instant to milliseconds bound to alongwithout throwingArithmeticException.- If the duration milliseconds are greater than
Long.MAX_VALUE, then returnLong.MAX_VALUE. - If the duration milliseconds are lesser than
Long.MIN_VALUE, then returnLong.MIN_VALUE. - If the instant is null, treat it as
Instant.EPOCH.
- Parameters:
instant- The instant to convert, not null.- Returns:
- long The given Instant in milliseconds.
- See Also:
- If the duration milliseconds are greater than
-
toInstant
Returns the given non-null instant, orInstant.EPOCHif null.- Parameters:
instant- The instant to test, may be null.- Returns:
- The given non-null instant, or
Instant.EPOCHif null.
-
toInstant
Returns the given non-null instant, ordefaultInstantif instant is null.- Parameters:
instant- The instant to test, may be null.defaultInstant- The default instant to use if the given instant is null, may be null.- Returns:
- The given non-null instant, or
defaultInstantif null.
-
toMillisSince
Converts an Instant to milliseconds since that Instant bound to alongwithout throwingArithmeticException.- If the duration milliseconds are greater than
Long.MAX_VALUE, then returnLong.MAX_VALUE. - If the duration milliseconds are lesser than
Long.MIN_VALUE, then returnLong.MIN_VALUE. - If the instant is null, treat it as
Instant.EPOCH.
- Parameters:
instant- The instant to convert, not null.- Returns:
- long The duration in milliseconds since the given Instant.
- If the duration milliseconds are greater than
-