public class DateTimeComparator
extends java.lang.Object
implements java.util.Comparator<java.lang.Object>, java.io.Serializable
Dates may be specified using any object recognised by the
ConverterManager
class.
The default objects recognised by the comparator are:
DateTimeComparator is thread-safe and immutable.
Modifier and Type | Field and Description |
---|---|
private static DateTimeComparator |
ALL_INSTANCE
Singleton instance
|
private static DateTimeComparator |
DATE_INSTANCE
Singleton instance
|
private DateTimeFieldType |
iLowerLimit
The lower limit of fields to compare, null if no limit
|
private DateTimeFieldType |
iUpperLimit
The upper limit of fields to compare, null if no limit
|
private static long |
serialVersionUID
Serialization lock
|
private static DateTimeComparator |
TIME_INSTANCE
Singleton instance
|
Modifier | Constructor and Description |
---|---|
protected |
DateTimeComparator(DateTimeFieldType lowerLimit,
DateTimeFieldType upperLimit)
Restricted constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object lhsObj,
java.lang.Object rhsObj)
Compare two objects against only the range of date time fields as
specified in the constructor.
|
boolean |
equals(java.lang.Object object)
Compares this comparator to another.
|
static DateTimeComparator |
getDateOnlyInstance()
Returns a comparator that only considers date fields.
|
static DateTimeComparator |
getInstance()
Returns a DateTimeComparator the compares the entire date time value.
|
static DateTimeComparator |
getInstance(DateTimeFieldType lowerLimit)
Returns a DateTimeComparator with a lower limit only.
|
static DateTimeComparator |
getInstance(DateTimeFieldType lowerLimit,
DateTimeFieldType upperLimit)
Returns a DateTimeComparator with a lower and upper limit.
|
DateTimeFieldType |
getLowerLimit()
Gets the field type that represents the lower limit of comparison.
|
static DateTimeComparator |
getTimeOnlyInstance()
Returns a comparator that only considers time fields.
|
DateTimeFieldType |
getUpperLimit()
Gets the field type that represents the upper limit of comparison.
|
int |
hashCode()
Gets a suitable hashcode.
|
private java.lang.Object |
readResolve()
Support serialization singletons.
|
java.lang.String |
toString()
Gets a debugging string.
|
private static final long serialVersionUID
private static final DateTimeComparator ALL_INSTANCE
private static final DateTimeComparator DATE_INSTANCE
private static final DateTimeComparator TIME_INSTANCE
private final DateTimeFieldType iLowerLimit
private final DateTimeFieldType iUpperLimit
protected DateTimeComparator(DateTimeFieldType lowerLimit, DateTimeFieldType upperLimit)
lowerLimit
- the lower field limit, null means no limitupperLimit
- the upper field limit, null means no limitpublic static DateTimeComparator getInstance()
public static DateTimeComparator getInstance(DateTimeFieldType lowerLimit)
The time-zone is considered when using this comparator. The input millis are truncated using the time-zone of that input value. Thus, two inputs with different time-zones will typically not be equal
lowerLimit
- inclusive lower limit for fields to be compared, null means no limitpublic static DateTimeComparator getInstance(DateTimeFieldType lowerLimit, DateTimeFieldType upperLimit)
The time-zone is considered when using this comparator unless both limits are null. The input millis are rounded/truncated using the time-zone of that input value. Thus, two inputs with different time-zones will typically not be equal
lowerLimit
- inclusive lower limit for fields to be compared, null means no limitupperLimit
- exclusive upper limit for fields to be compared, null means no limitpublic static DateTimeComparator getDateOnlyInstance()
The time-zone is considered when using this comparator. The input millis are rounded down to the start of the day in the time-zone of that input value. Thus, two inputs with different time-zones will typically not be equal
public static DateTimeComparator getTimeOnlyInstance()
The time-zone is considered when using this comparator. The input millis are truncated to be within the day in the time-zone of that input value. Thus, two inputs with different time-zones will typically not be equal
public DateTimeFieldType getLowerLimit()
public DateTimeFieldType getUpperLimit()
public int compare(java.lang.Object lhsObj, java.lang.Object rhsObj)
compare
in interface java.util.Comparator<java.lang.Object>
lhsObj
- the first object,
logically on the left of a < comparison, null means nowrhsObj
- the second object,
logically on the right of a < comparison, null means nowjava.lang.IllegalArgumentException
- if either argument is not supportedprivate java.lang.Object readResolve()
public boolean equals(java.lang.Object object)
equals
in interface java.util.Comparator<java.lang.Object>
equals
in class java.lang.Object
object
- the object to compare topublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object