Class DateUtil
java.lang.Object
org.broadleafcommerce.common.util.DateUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DategetCurrentDateAfterFactoringInDateResolution(Date cachedDate, Long currentDateResolution) static booleanDetermine 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 <= endDateIf
startDateisnullthen the date range is inactive. IfendDateis null, then only thestartDateis 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 theDateto be used in a query based on a cachedDateand 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 aDateuntil it has exceeded the resolution, at which point the current timestamp will be used.NOTE: This method will update the passed in
cachedDateif the resolution has passed.
-