Enum Class DateType
- All Implemented Interfaces:
Serializable,Comparable<DateType>,Constable
The
DateType enumeration provides a set of known date
formats supported by the date transformer. This allows the XML
representation of a date to come in several formats, from most
accurate to least. Enumerating the dates ensures that resolution
of the format is fast by enabling inspection of the date string.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classTheDateFormatprovides a synchronized means for using the simple date format object.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DateType.DateFormatThis is the date formatter that is used to parse the date. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DateThis is used to convert the string to a date value.private DateType.DateFormatAcquires the date format from the date type.static StringThis is used to convert the date to a string value.static DateTypeThis is used to acquire a date type using the specified text as input.static DateTypeReturns the enum constant of this class with the specified name.static DateType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FULL
This is the default date format used by the date transform. -
LONG
This is the date type without millisecond resolution. -
NORMAL
This date type enables only the specific date to be used. -
SHORT
This is the shortest format that relies on the date locale.
-
-
Field Details
-
format
This is the date formatter that is used to parse the date.
-
-
Constructor Details
-
DateType
Constructor for theDateTypeenumeration. This will accept a simple date format pattern, which is used to parse an input string and convert it to a usable date.- Parameters:
format- this is the format to use to parse the date
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getFormat
Acquires the date format from the date type. This is then used to parse the date string and convert it to a usable date. The format returned is synchronized for safety.- Returns:
- this returns the date format to be used
-
getText
This is used to convert the date to a string value. The string value can then be embedded in to the generated XML in such a way that it can be recovered as aDatewhen the value is transformed by the date transform.- Parameters:
date- this is the date that is converted to a string- Returns:
- this returns the string to represent the date
- Throws:
Exception
-
getDate
This is used to convert the string to a date value. The date value can then be recovered from the generated XML by parsing the text with one of the known date formats. This allows bidirectional transformation of dates to strings.- Parameters:
text- this is the date that is converted to a date- Returns:
- this returns the date parsed from the string value
- Throws:
Exception
-
getType
This is used to acquire a date type using the specified text as input. This will perform some checks on the raw string to match it to the appropriate date type. Resolving the date type in this way ensures that only one date type needs to be used.- Parameters:
text- this is the text to be matched with a date type- Returns:
- the most appropriate date type for the given string
-