Date Validation and Conversion routines (java.util.Date
).
This validator provides a number of methods for validating/converting a String
date value to a java.util.Date
using java.text.DateFormat
to parse either:
Locale
Locale
Locale
Locale
For each of the above mechanisms, conversion method (i.e the validate
methods) implementations are provided which either use the default TimeZone
or allow the TimeZone
to be specified.
Use one of the isValid()
methods to just validate or one of the validate()
methods to validate and receive a converted Date
value.
Implementations of the validate()
method are provided to create Date
objects for different time zones if the system default is not appropriate.
Once a value has been sucessfully converted the following methods can be used to perform various date comparison checks:
compareDates()
compares the day, month and year of two dates, returing 0, -1 or +1 indicating whether the first date is equal, before or after the second.compareWeeks()
compares the week and year of two dates, returing 0, -1 or +1 indicating whether the first week is equal, before or after the second.compareMonths()
compares the month and year of two dates, returing 0, -1 or +1 indicating whether the first month is equal, before or after the second.compareQuarters()
compares the quarter and year of two dates, returing 0, -1 or +1 indicating whether the first quarter is equal, before or after the second.compareYears()
compares the year of two dates, returing 0, -1 or +1 indicating whether the first year is equal, before or after the second.So that the same mechanism used for parsing an input value for validation can be used to format output, corresponding format()
methods are also provided. That is you can format either:
Locale
Locale
Validator
that simply checks for a non-null Date
. Uses the converted value, so needs to be used in conjunction with a date Converter
@author Phil Zoio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|