public static class DateRange.DateRangeBound extends Object
Date
field and
a corresponding DateRange.DateRangeBound.Precision
.
Date range bounds are inclusive.
The special value UNBOUNDED
denotes an un unbounded (infinite) bound,
represented by a *
sign.
DateRangeBound
instances are immutable and thread-safe.Modifier and Type | Class and Description |
---|---|
static class |
DateRange.DateRangeBound.Precision
The precision of a
DateRange.DateRangeBound . |
Modifier and Type | Field and Description |
---|---|
static DateRange.DateRangeBound |
UNBOUNDED
The unbounded
DateRange.DateRangeBound instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
DateRange.DateRangeBound.Precision |
getPrecision()
Returns the precision of this bound.
|
Date |
getTimestamp()
Returns the timestamp of this bound.
|
int |
hashCode() |
boolean |
isUnbounded()
Whether this bound is an unbounded bound.
|
static DateRange.DateRangeBound |
lowerBound(Date timestamp,
DateRange.DateRangeBound.Precision precision)
Creates a date range lower bound from the given
Date and DateRange.DateRangeBound.Precision . |
static DateRange.DateRangeBound |
parseLowerBound(String lowerBound)
Parses the given input as a lower date range bound.
|
static DateRange.DateRangeBound |
parseUpperBound(String upperBound)
Parses the given input as an upper date range bound.
|
String |
toString()
Returns this
bound as a Lucene-compliant string. |
static DateRange.DateRangeBound |
upperBound(Date timestamp,
DateRange.DateRangeBound.Precision precision)
Creates a date range upper bound from the given
Date and DateRange.DateRangeBound.Precision . |
public static final DateRange.DateRangeBound UNBOUNDED
DateRange.DateRangeBound
instance. Unbounded bounds
are syntactically represented by a *
(star) sign.public static DateRange.DateRangeBound parseLowerBound(String lowerBound) throws ParseException
bound
will have its precision
inferred from
the input, and its timestamp will be rounded down
to that precision.lowerBound
- The lower date range bound to parse; must not be null
.DateRange.DateRangeBound
.IllegalArgumentException
- if lowerBound
is null
.ParseException
- if the given input cannot be parsed.public static DateRange.DateRangeBound parseUpperBound(String upperBound) throws ParseException
bound
will have its precision
inferred from
the input, and its timestamp will be DateRange.DateRangeBound.Precision.roundUp(Date)
rounded up} to that precision.upperBound
- The upper date range bound to parse; must not be null
.DateRange.DateRangeBound
.IllegalArgumentException
- if upperBound
is null
.ParseException
- if the given input cannot be parsed.public static DateRange.DateRangeBound lowerBound(Date timestamp, DateRange.DateRangeBound.Precision precision)
Date
and DateRange.DateRangeBound.Precision
.
Temporal fields smaller than the precision will be rounded down.timestamp
- The timestamp to use.precision
- The precision to use.public static DateRange.DateRangeBound upperBound(Date timestamp, DateRange.DateRangeBound.Precision precision)
Date
and DateRange.DateRangeBound.Precision
.
Temporal fields smaller than the precision will be rounded up.timestamp
- The timestamp to use.precision
- The precision to use.public boolean isUnbounded()
public Date getTimestamp()
public DateRange.DateRangeBound.Precision getPrecision()
public String toString()
bound
as a Lucene-compliant string.
Unbounded bounds always return "*
"; all other bounds
are formatted in one of the common ISO-8601 datetime formats,
depending on their precision.
Note that Lucene expects timestamps in UTC only.
Timezone presence is always optional, and if present,
it must be expressed with the symbol "Z" exclusively.
Therefore this method does not include any timezone
information in the returned string, except for bounds with
millisecond
precision, where
the symbol "Z" is always appended to the resulting string.toString
in class Object
DateRange.DateRangeBound
as a Lucene-compliant string.Copyright © 2012–2018. All rights reserved.