public class RelativeDate extends Date
bean.setDate(RelativeDate.NOW)
bean.setDate(RelativeDate.TODAY)
bean.setDate(new RelativeDate(RelativeDate.TODAY, - DateUtils.MILLIS_PER_DAY))
Modifier and Type | Class and Description |
---|---|
static class |
RelativeDate.Precision
The precision of a difference between a reference date and a date property.
|
static class |
RelativeDate.ReferenceDate
|
Modifier and Type | Field and Description |
---|---|
static RelativeDate.Precision |
DAYS
Used for adding days to a reference date.
|
static RelativeDate.Precision |
HOURS
Used for adding hours to a reference date.
|
static RelativeDate.Precision |
MILLISECONDS
Used for adding milliseconds to a reference date.
|
static RelativeDate.Precision |
MINUTES
Used for adding minutes to a reference date.
|
static RelativeDate.ReferenceDate |
NOW
Represents the constant for writing the "now" function to SQL.
|
private static RelativeDate.Precision[] |
PRECISIONS
All known precisions, from the smallest to the biggest.
|
private RelativeDate.ReferenceDate |
referenceDate
The date that is the base for this date.
|
static RelativeDate.Precision |
SECONDS
Used for adding seconds to a reference date.
|
private static long |
serialVersionUID |
static RelativeDate.ReferenceDate |
TODAY
Represents the constant for writing the "today" function to SQL.
|
static RelativeDate.Precision |
WEEKS
Used for adding weeks to a reference date.
|
static RelativeDate.Precision |
YEARS
Used for adding years to a reference date.
|
Constructor and Description |
---|
RelativeDate(long timeInMillis)
Creates a new instance with the given millis as time.
|
RelativeDate(RelativeDate.ReferenceDate referenceDate,
long deltaInMillis)
Creates a new instance with the given millis as time and the given reference date.
|
RelativeDate(RelativeDate.ReferenceDate referenceDate,
long delta,
RelativeDate.Precision precision)
Creates a new difference to a given reference date.
|
Modifier and Type | Method and Description |
---|---|
long |
getDifference()
The difference of the time to the
referenceDate . |
RelativeDate.Precision |
getPrecision()
Finds the highest possible unit of the difference between the reference date and this date.
|
RelativeDate.ReferenceDate |
getReferenceDate()
The date that is the base for this date.
|
after, before, clone, compareTo, equals, from, getDate, getDay, getHours, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getYear, hashCode, parse, setDate, setHours, setMinutes, setMonth, setSeconds, setTime, setYear, toGMTString, toInstant, toLocaleString, toString, UTC
private static final long serialVersionUID
public static final RelativeDate.ReferenceDate TODAY
public static final RelativeDate.ReferenceDate NOW
public static final RelativeDate.Precision MILLISECONDS
public static final RelativeDate.Precision SECONDS
public static final RelativeDate.Precision MINUTES
public static final RelativeDate.Precision HOURS
public static final RelativeDate.Precision DAYS
public static final RelativeDate.Precision WEEKS
public static final RelativeDate.Precision YEARS
private static final RelativeDate.Precision[] PRECISIONS
private final RelativeDate.ReferenceDate referenceDate
public RelativeDate(long timeInMillis)
NOW
as reference date.timeInMillis
- the time in milliseconds. Only the difference to NOW
is written to SQLpublic RelativeDate(RelativeDate.ReferenceDate referenceDate, long deltaInMillis)
referenceDate
- the reference datedeltaInMillis
- the difference to the reference date in millisecondspublic RelativeDate(RelativeDate.ReferenceDate referenceDate, long delta, RelativeDate.Precision precision)
referenceDate
- the reference datedelta
- the difference to the reference dateprecision
- the unit of the delta, one of the constants defined abovepublic long getDifference()
referenceDate
.public RelativeDate.Precision getPrecision()
@Generated(value="lombok") public RelativeDate.ReferenceDate getReferenceDate()
Copyright © 2022 fastnate.org. All rights reserved.