|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object velosurf.validation.FieldConstraint velosurf.validation.DateRange
public class DateRange
A type and range constraint on dates. Syntax is:
<column [type="date"] [after="date-after"] [before="date-before"] />
The type="date"
parameter is implied when after
or before
is found.
Or:
<column>
<date [after="afer-date"] [before="before-date"] [format="SimpleDateFormat
format"] [message="error-message"] />
</column>
The format used to specify after and before dates is always yyyyMMdd
. The format used to parse the input
is by default the short local date format (which depends upon the user locale) but can be configured using the format attribute.
Field Summary | |
---|---|
private java.util.Date |
after
afer date |
private java.util.Date |
before
before date |
private java.text.SimpleDateFormat |
dateFormat
date format |
private static java.util.regex.Pattern |
y4
'YYYY' date format. |
private static java.text.DateFormat |
ymd
yyyyMMdd date format. |
Constructor Summary | |
---|---|
DateRange()
Constructor. |
Method Summary | |
---|---|
private static java.lang.String |
reformat(java.lang.String pattern,
java.lang.String date)
tries to reformat the date to match pattern conventions |
void |
setAfterDate(java.util.Date after)
After date constraint setter. |
void |
setBeforeDate(java.util.Date before)
Before date constraint setter. |
void |
setDateFormat(java.text.SimpleDateFormat dateFormat)
date format setter. |
java.lang.String |
toString()
return a string representation for this constraint. |
boolean |
validate(java.lang.Object data,
java.util.Locale locale)
Validate data against this constraint. |
Methods inherited from class velosurf.validation.FieldConstraint |
---|
getMessage, setMessage, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.Date before
private java.util.Date after
private java.text.SimpleDateFormat dateFormat
private static final java.util.regex.Pattern y4
private static java.text.DateFormat ymd
Constructor Detail |
---|
public DateRange()
Method Detail |
---|
public void setBeforeDate(java.util.Date before)
before
- before datepublic void setAfterDate(java.util.Date after)
after
- afet datepublic boolean validate(java.lang.Object data, java.util.Locale locale)
validate
in class FieldConstraint
data
- data to validatelocale
- locale to use
private static java.lang.String reformat(java.lang.String pattern, java.lang.String date)
pattern
- date patterndate
- date
public java.lang.String toString()
toString
in class java.lang.Object
public void setDateFormat(java.text.SimpleDateFormat dateFormat)
dateFormat
- date format
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |