public class SimpleDateConverter extends Object
The getAsObject() method parses a String into a
java.util.Date, according to the following algorithm:
null. Otherwise,
trim leading and trailing whitespace before proceeding.null.displayRule has been specified, its syntax must conform
the rules specified by java.text.SimpleDateFormat. Such a
displayRule will be used to parse, and the type,
dateStyle, and timeStyle properties will be
ignored.displayRule has not been specified, parsing will be
based on the type property, which expects a date value, a time
value, or both. Any date and time values included will be parsed in
accordance to the styles specified by dateStyle and
timeStyle, respectively.
The getAsString() method expects a value of type
java.util.Date (or a subclass), and creates a formatted String
according to the following algorithm:
displayRule has been specified, its syntax must conform
the rules specified by java.text.SimpleDateFormat. Such a
displayRule will be used to format, and the dataType,
dateStyle, and timeStyle properties will be
ignored.displayRule has not been specified, formatting will be
based on the dataType property, which includes a date value, a
time value, or both into the formatted String. Any date and time values
included will be formatted in accordance to the styles specified by
dateStyle and timeStyle, respectively.| Constructor and Description |
|---|
SimpleDateConverter(String dataType,
String displayRule)
Create a new g9 date converter.
|
SimpleDateConverter(String dataType,
String displayRule,
Locale locale)
Create a new g9 date converter.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
getAsObject(String value)
Convert the specified string value from a field, into a model data object
that is appropriate for being stored during the Apply Request Values
phase of the request processing life cycle.
|
String |
getAsString(Object value) |
String |
getDataType() |
String |
getDefaultStyle() |
String |
getDisplayRule() |
void |
setDataType(String dataType) |
void |
setDefaultStyle(String defaultStyle) |
void |
setDisplayRule(String displayRule)
Set the format displayRule to be used when formatting and parsing dates
and times.
|
public SimpleDateConverter(String dataType, String displayRule, Locale locale)
dataType - to be converteddisplayRule - for the fieldlocale - for the converterpublic Object getAsObject(String value)
value - to be convertedpublic String getAsString(Object value)
value - to convertpublic void setDisplayRule(String displayRule)
Set the format displayRule to be used when formatting and parsing dates
and times. Valid values are those supported by
java.text.SimpleDateFormat. An invalid value will cause a
SimpleDateConverterException when getAsObject() or
getAsString() is called.
displayRule - The new format displayRulepublic String getDisplayRule()
public void setDataType(String dataType)
dataType - to be setpublic String getDataType()
public String getDefaultStyle()
public void setDefaultStyle(String defaultStyle)
defaultStyle - to be setCopyright © 2006–2020 Esito AS. All rights reserved.