Converter implementation for
java.util.Date values.
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.locale property is not null, use that Locale for managing parsing. Otherwise, use the
Locale from the UIViewRoot.pattern has been specified, its syntax must conform the rules specified by
java.text.SimpleDateFormat or java.time.format.DateTimeFormatter. Which of these two formatters is used depends on the value of type. Such a
pattern will be used to parse, and the type, dateStyle, and timeStyle properties will
be ignored, unless the value of type is one of the java.time specific values listed in setType. In this case,
DateTimeFormatter.ofPattern(String, Locale) must be called, passing the value of pattern as the first argument
and the current Locale as the second argument, and this formatter must be used to parse the incoming
value.pattern has not been specified, parsing will be based on the type property, which expects a
date value, a time value, both, or one of several values specific to classes in
java.time as listed in setType. Any date and time values included will be parsed in accordance to the
styles specified by dateStyle and timeStyle, respectively.timezone has been specified, it must be passed to the underlying DateFormat instance.
Otherwise the "GMT" timezone is used.
The getAsString() method expects a value of type java.util.Date (or a subclass), and creates a
formatted String according to the following algorithm:
locale property is not null, use that Locale for managing formatting. Otherwise, use the
Locale from the UIViewRoot.timezone has been specified, it must be passed to the underlying DateFormat instance.
Otherwise the "GMT" timezone is used.pattern has been specified, its syntax must conform the rules specified by
java.text.SimpleDateFormat or java.time.format.DateTimeFormatter. Which of these two formatters is used depends on the value of type. Such a
pattern will be used to format, and the type, dateStyle, and timeStyle properties will
be ignored, unless the value of type is one of the java.time specific values listed in setType. In this case, DateTimeFormatter.ofPattern(String, Locale) must be called, passing the value of pattern as the first argument and
the current Locale as the second argument, and this formatter must be used to format the outgoing value.pattern has not been specified, formatting will be based on the type property, which
includes a date value, a time value, both or into the formatted String. Any date and time values included will be formatted in
accordance to the styles specified by dateStyle and timeStyle, respectively.| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | CONVERTER_ID
The standard converter id for this converter. |
| public static final String | DATE_ID
The message identifier of the |
| private String | |
| public static final String | DATETIME_ID
The message identifier of the |
| private static final TimeZone | |
| private boolean | |
| private Locale | |
| private String | |
| public static final String | STRING_ID
The message identifier of the |
| public static final String | TIME_ID
The message identifier of the |
| private String | |
| private TimeZone | |
| private boolean | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clearInitialState()
Implements jakarta. Reset the PartialStateHolder to a non-delta tracking state. |
| public Object | getAsObject(FacesContext
FacesContext for the request being processedUIComponent with which this model object value is associatedString value to be converted (may be value)null)Implements jakarta.
Convert the specified string value, which is associated with the specified
|
| public String | getAsString(FacesContext
FacesContext for the request being processedUIComponent with which this model object value is associatedModel object value to be converted (may be value)null)Implements jakarta.
Convert the specified model object value, which is associated with the specified |
| private DateTimeConverter. | getDateFormat(Locale
The locale)Locale used to select formatting and parsing conventions
Return a |
| public String | |
| private static FormatStyle | |
| public Locale | Returns: theLocale
Return the |
| private Locale | getLocale(FacesContext
The context)FacesContext for the current request
Return the |
| public String | Returns: the patternReturn the format pattern to be used when formatting and parsing dates and times. |
| private static int | |
| public String | |
| public TimeZone | |
| public String | |
| public boolean | initialStateMarked()
Implements jakarta.
Return |
| private static boolean | |
| public boolean | isTransient()
Implements jakarta. If true, the Object implementing this interface must not participate in state saving or restoring. |
| public void | markInitialState()
Implements jakarta.
The runtime must ensure that the |
| public void | restoreState(FacesContext
the Faces context. context, Object the state. state)Implements jakarta. Perform any processing required to restore the state from the entries in the state Object. |
| public Object | saveState(FacesContext
the Faces context. context)Implements jakarta.
Gets the state of the instance as a |
| public void | |
| public void | |
| public void | setPattern(String
The new format pattern pattern)Set the format pattern to be used when formatting and parsing dates and times. |
| public void | |
| public void | |
| public void | setTransient(boolean
boolean pass transientFlag)true if this Object will
not participate in state saving or restoring, otherwise pass false.Implements jakarta. Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring. |
| public void |
| CONVERTER_ID | back to summary |
|---|---|
| public static final String CONVERTER_ID The standard converter id for this converter. | |
| DATE_ID | back to summary |
|---|---|
| public static final String DATE_ID
The message identifier of the
| |
| dateStyle | back to summary |
|---|---|
| private String dateStyle | |
| DATETIME_ID | back to summary |
|---|---|
| public static final String DATETIME_ID
The message identifier of the
| |
| DEFAULT_TIME_ZONE | back to summary |
|---|---|
| private static final TimeZone DEFAULT_TIME_ZONE | |
| initialState | back to summary |
|---|---|
| private boolean initialState | |
| locale | back to summary |
|---|---|
| private Locale locale | |
| pattern | back to summary |
|---|---|
| private String pattern | |
| STRING_ID | back to summary |
|---|---|
| public static final String STRING_ID
The message identifier of the
| |
| TIME_ID | back to summary |
|---|---|
| public static final String TIME_ID
The message identifier of the
| |
| timeStyle | back to summary |
|---|---|
| private String timeStyle | |
| timeZone | back to summary |
|---|---|
| private TimeZone timeZone | |
| transientFlag | back to summary |
|---|---|
| private boolean transientFlag | |
| type | back to summary |
|---|---|
| private String type | |
| DateTimeConverter | back to summary |
|---|---|
| public DateTimeConverter() | |
| clearInitialState | back to summary |
|---|---|
| public void clearInitialState() Implements jakarta. Doc from jakarta. Reset the PartialStateHolder to a non-delta tracking state.
| |
| getAsObject | back to summary |
|---|---|
| public Object getAsObject(FacesContext context, UIComponent component, String value) Implements jakarta. Doc from jakarta.
Convert the specified string value, which is associated with the specified
| |
| getAsString | back to summary |
|---|---|
| public String getAsString(FacesContext context, UIComponent component, Object value) Implements jakarta. Doc from jakarta.
Convert the specified model object value, which is associated with the specified
| |
| getDateFormat | back to summary |
|---|---|
| private DateTimeConverter.
Return a
| |
| getDateStyle | back to summary |
|---|---|
| public String getDateStyle()
Return the style to be used to format or parse dates. If not set, the default value,
| |
| getFormatStyle | back to summary |
|---|---|
| private static FormatStyle getFormatStyle(String name) | |
| getLocale | back to summary |
|---|---|
| public Locale getLocale()
Return the
| |
| getLocale | back to summary |
|---|---|
| private Locale getLocale(FacesContext context)
Return the
| |
| getPattern | back to summary |
|---|---|
| public String getPattern() Return the format pattern to be used when formatting and parsing dates and times.
| |
| getStyle | back to summary |
|---|---|
| private static int getStyle(String name) Return the style constant for the specified style name.
| |
| getTimeStyle | back to summary |
|---|---|
| public String getTimeStyle()
Return the style to be used to format or parse times. If not set, the default value,
| |
| getTimeZone | back to summary |
|---|---|
| public TimeZone getTimeZone()
Return the
| |
| getType | back to summary |
|---|---|
| public String getType()
Return the type of value to be formatted or parsed. If not explicitly set, the default type,
| |
| initialStateMarked | back to summary |
|---|---|
| public boolean initialStateMarked() Implements jakarta. Doc from jakarta.
Return
| |
| isJavaTimeType | back to summary |
|---|---|
| private static boolean isJavaTimeType(String type) | |
| isTransient | back to summary |
|---|---|
| public boolean isTransient() Implements jakarta. Doc from jakarta. If true, the Object implementing this interface must not participate in state saving or restoring.
| |
| markInitialState | back to summary |
|---|---|
| public void markInitialState() Implements jakarta. Doc from jakarta.
The runtime must ensure that the
| |
| restoreState | back to summary |
|---|---|
| public void restoreState(FacesContext context, Object state) Implements jakarta. Doc from jakarta. Perform any processing required to restore the state from the entries in the state Object.
If the class that implements this interface has references to instances that also implement StateHolder (such as a
If the
| |
| saveState | back to summary |
|---|---|
| public Object saveState(FacesContext context) Implements jakarta. Doc from jakarta.
Gets the state of the instance as a
If the class that implements this interface has references to instances that implement StateHolder (such as a
This method must not alter the state of the implementing object. In other words, after executing this code:
The return from this method must be
| |
| setDateStyle | back to summary |
|---|---|
| public void setDateStyle(String dateStyle)
Set the style to be used to format or parse dates. Valid values are
| |
| setLocale | back to summary |
|---|---|
| public void setLocale(Locale locale)
Set the
| |
| setPattern | back to summary |
|---|---|
| public void setPattern(String pattern)
Set the format pattern to be used when formatting and parsing dates and times. Valid values are those supported by
| |
| setTimeStyle | back to summary |
|---|---|
| public void setTimeStyle(String timeStyle)
Set the style to be used to format or parse times. Valid values are
| |
| setTimeZone | back to summary |
|---|---|
| public void setTimeZone(TimeZone timeZone)
Set the
| |
| setTransient | back to summary |
|---|---|
| public void setTransient(boolean transientFlag) Implements jakarta. Doc from jakarta. Denotes whether or not the Object implementing this interface must or must not participate in state saving or restoring.
| |
| setType | back to summary |
|---|---|
| public void setType(String type)
Set the type of value to be formatted or parsed. Valid values are
| |
| Modifier and Type | Field and Description |
|---|---|
| private final DateFormat | |
| private final DateTimeFormatter | |
| private final TemporalQuery |
| Access | Constructor and Description |
|---|---|
| private | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| private String | |
| private String | |
| private Object | |
| private void |
| dateFormat | back to summary |
|---|---|
| private final DateFormat dateFormat | |
| dateTimeFormatter | back to summary |
|---|---|
| private final DateTimeFormatter dateTimeFormatter | |
| from | back to summary |
|---|---|
| private final TemporalQuery<Object> from | |
| FormatWrapper | back to summary |
|---|---|
| private FormatWrapper(DateFormat dataFormat) | |
| FormatWrapper | back to summary |
|---|---|
| private FormatWrapper(DateTimeFormatter dateTimeFormatter, TemporalQuery<Object> from) | |
| format | back to summary |
|---|---|
| private String format(Object obj) | |
| formatNow | back to summary |
|---|---|
| private String formatNow() | |
| parse | back to summary |
|---|---|
| private Object parse(CharSequence text) throws ParseException | |
| setTimeZone | back to summary |
|---|---|
| private void setTimeZone(TimeZone zone) | |