public class DateIntervalConstraint extends AbstractConstraint
This constraint can validate any Date
or Calendar
. This constraint also support Number
types
whose long value is recognised as number of milliseconds since January 1, 1970, 00:00:00 GMT. The constraint finally
supports String having YYYY-MM-DD format.
Constraint.Description
MESSAGES_BUNDLE, MESSAGES_DEFAULT_LANG, MESSAGES_KEY
Constructor and Description |
---|
DateIntervalConstraint(Object minDate,
boolean includingMin,
Object maxDate,
boolean includingMax)
Use null value to disable a bound.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Constraint.Description |
getDescription()
Here, value is :
name = . |
String |
getErrorMessage(Object invalidValue,
Locale locale)
Provides an error message to display when some invalid value does not match existing entity.
|
Long |
getMaxTime() |
Long |
getMinTime() |
int |
hashCode() |
boolean |
isIncludingMax() |
boolean |
isIncludingMin() |
boolean |
validate(Object object)
Validates the given object against this constraint.
|
getMessageString, toString
public DateIntervalConstraint(Object minDate, boolean includingMin, Object maxDate, boolean includingMax)
Bounds could be any Date
or Calendar
. Bounds also support Number
types whose long value
is recognised as number of milliseconds since January 1, 1970, 00:00:00 GMT. Bounds finally supports String
having YYYY-MM-DD format.
Invalid bound (wrong format) would be ignored with log warning.
minDate
- The lower bound of the intervalincludingMin
- true if the lower bound is included in the intervalmaxDate
- The upper bound of the intervalincludingMax
- true if the upper bound is included in the intervalpublic boolean validate(Object object)
Constraint
If some object is null. Constraint should return true while validating unless the constraint deals with nullable state.
object
- the object to validatepublic Constraint.Description getDescription()
public Long getMinTime()
public Long getMaxTime()
public boolean isIncludingMin()
public boolean isIncludingMax()
public String getErrorMessage(Object invalidValue, Locale locale)
Constraint
getErrorMessage
in interface Constraint
getErrorMessage
in class AbstractConstraint
invalidValue
- The invalid value that don't match any entity.locale
- The language in which the message should be generated.Copyright © 2015 Nuxeo SA. All rights reserved.