Class DateUtil
java.lang.Object
org.broadleafcommerce.common.util.DateUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final long
static final long
static final long
static final long
static final long
static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Date
getCurrentDateAfterFactoringInDateResolution
(Date cachedDate, Long currentDateResolution) static boolean
Determine if a date range is active.
-
Field Details
-
ONE_HOUR_MILLIS
public static final long ONE_HOUR_MILLIS- See Also:
-
ONE_DAY_MILLIS
public static final long ONE_DAY_MILLIS- See Also:
-
ONE_WEEK_MILLIS
public static final long ONE_WEEK_MILLIS- See Also:
-
ONE_HOUR_SECONDS
public static final long ONE_HOUR_SECONDS- See Also:
-
ONE_DAY_SECONDS
public static final long ONE_DAY_SECONDS- See Also:
-
ONE_WEEK_SECONDS
public static final long ONE_WEEK_SECONDS- See Also:
-
SIX_MONTHS_SECONDS
public static final long SIX_MONTHS_SECONDS- See Also:
-
-
Constructor Details
-
DateUtil
public DateUtil()
-
-
Method Details
-
isActive
Determine if a date range is active.A date range is active if the following statement is true:
startDate < now <= endDate
If
startDate
isnull
then the date range is inactive. IfendDate
is null, then only thestartDate
is checked.- Parameters:
includeTime
- If true, then the full timestamp to the millisecond is used. If false, only the date will be used and the time is zeroed out.- Returns:
- True if the date range is currently active, false otherwise.
-
getCurrentDateAfterFactoringInDateResolution
public static Date getCurrentDateAfterFactoringInDateResolution(Date cachedDate, Long currentDateResolution) Return theDate
to be used in a query based on a cachedDate
and a resolution.This is meant to be used as a mechanism to allow caching to occur in queries that compare a date to
now
. Since caching will only occur if the query is exactly the same, you cannot use the exact current timestamp or the query will never be cached. This method will return the same timestamp for aDate
until it has exceeded the resolution, at which point the current timestamp will be used.NOTE: This method will update the passed in
cachedDate
if the resolution has passed.
-