Package com.nimbusds.jose.util
Class DateUtils
- java.lang.Object
-
- com.nimbusds.jose.util.DateUtils
-
@Deprecated public class DateUtils extends Object
Deprecated.Date utilities. UseDateUtils
instead.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Date
fromSecondsSinceEpoch(long time)
Deprecated.Converts the specified Unix epoch time in seconds to a date object.static boolean
isAfter(Date date, Date reference, long maxClockSkewSeconds)
Deprecated.Check if the specified date is after the specified reference, given the maximum accepted negative clock skew.static boolean
isBefore(Date date, Date reference, long maxClockSkewSeconds)
Deprecated.Checks if the specified date is before the specified reference, given the maximum accepted positive clock skew.static long
toSecondsSinceEpoch(Date date)
Deprecated.Converts the specified date object to a Unix epoch time in seconds.
-
-
-
Method Detail
-
toSecondsSinceEpoch
public static long toSecondsSinceEpoch(Date date)
Deprecated.Converts the specified date object to a Unix epoch time in seconds.- Parameters:
date
- The date. Must not benull
.- Returns:
- The Unix epoch time, in seconds.
-
fromSecondsSinceEpoch
public static Date fromSecondsSinceEpoch(long time)
Deprecated.Converts the specified Unix epoch time in seconds to a date object.- Parameters:
time
- The Unix epoch time, in seconds. Must not be negative.- Returns:
- The date.
-
isAfter
public static boolean isAfter(Date date, Date reference, long maxClockSkewSeconds)
Deprecated.Check if the specified date is after the specified reference, given the maximum accepted negative clock skew.Formula:
return date + clock_skew > reference
Example: Ensure a JWT expiration (exp) timestamp is after the current time, with a minute of acceptable clock skew.boolean valid = DateUtils.isAfter(exp, new Date(), 60);
- Parameters:
date
- The date to check. Must not benull
.reference
- The reference date (e.g. the current time). Must not benull
.maxClockSkewSeconds
- The maximum acceptable negative clock skew of the date value to check, in seconds.- Returns:
true
if the date is before the reference, plus the maximum accepted clock skew, elsefalse
.
-
isBefore
public static boolean isBefore(Date date, Date reference, long maxClockSkewSeconds)
Deprecated.Checks if the specified date is before the specified reference, given the maximum accepted positive clock skew.Formula:
return date - clock_skew < reference
Example: Ensure a JWT issued-at (iat) timestamp is before the current time, with a minute of acceptable clock skew.boolean valid = DateUtils.isBefore(iat, new Date(), 60);
- Parameters:
date
- The date to check. Must not benull
.reference
- The reference date (e.g. the current time). Must not benull
.maxClockSkewSeconds
- The maximum acceptable clock skew of the date value to check, in seconds.- Returns:
true
if the date is before the reference, minus the maximum accepted clock skew, elsefalse
.
-
-