public class DateUtil extends Object
Modifier and Type | Field and Description |
---|---|
static long |
ONE_DAY_MILLIS |
static long |
ONE_DAY_SECONDS |
static long |
ONE_HOUR_MILLIS |
static long |
ONE_HOUR_SECONDS |
static long |
ONE_WEEK_MILLIS |
static long |
ONE_WEEK_SECONDS |
static long |
SIX_MONTHS_SECONDS |
Constructor and Description |
---|
DateUtil() |
Modifier and Type | Method and Description |
---|---|
static Date |
getCurrentDateAfterFactoringInDateResolution(Date cachedDate,
Long currentDateResolution)
|
static boolean |
isActive(Date startDate,
Date endDate,
boolean includeTime)
Determine if a date range is active.
|
public static final long ONE_HOUR_MILLIS
public static final long ONE_DAY_MILLIS
public static final long ONE_WEEK_MILLIS
public static final long ONE_HOUR_SECONDS
public static final long ONE_DAY_SECONDS
public static final long ONE_WEEK_SECONDS
public static final long SIX_MONTHS_SECONDS
public static boolean isActive(Date startDate, Date endDate, boolean includeTime)
A date range is active if the following statement is true: startDate < now <= endDate
If startDate
is null
then the date range is inactive. If endDate
is null, then only the
startDate
is checked.
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.public static Date getCurrentDateAfterFactoringInDateResolution(Date cachedDate, Long currentDateResolution)
Date
to be used in a query based on a cached Date
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 a Date
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.
Copyright © 2022. All rights reserved.