Oracle Fusion Middleware Tag Reference for Oracle ADF Faces
11g Release 2 (11.1.2.0.0)

E17491-02

<af:convertDateTime>

af:convertDateTime convertDateTime convert date time DateTime datetime

type: oracle.adf.rich.DateTime

Converts string into java.util.Date and vice versa based on the pattern and style set.

The default dateStyle is shortish. Shortish is identical to short but forces the year to be a full four digits. dateStyle defaults to shortish if it was not set.

Timezone can be set per web-app in adf-faces-config.xml configuration file. If timeZone is not set on the converter, then timezone will be defaulted to the value set in adf-faces-config.xml configuration file. If it is not set in the configuration file, then it will be defaulted to GMT.

The converter always allows a level of leniency while converting user input value to date to the following extent.

For example:
When pattern on the converter is set to "MMM/d/yyyy" the following inputs are tolerated as valid by the converter.

Jan/4/2004
Jan-4-2004
Jan.4.2004
01/4/2004
01-4-2004
01.4.2004
1/4/2004
1-4-2004
1.4.2004

The converter supports the same parsing/formatting conventions as the JDK SimpleDateFormat (specified using the dateStyle, timeStyle and pattern attributes) except:

This converter provides a format hint for the help framework, which cannot be turned off.

This converter is automatically registered under the standard converter ID, and therefore will be used when the <f:convertDateTime> tag is used.

This converter also runs on the client (implements org.apache.myfaces.trinidad.convert.ClientConverter).

If you derive a class from af:convertDateTime, it will not work with af:inputDate unless you also implement ClientConverter.

Attributes

Name Type Supports EL? Description
dateStyle String Yes Default Value: shortish

Predefined formatting style which determines how the date component of a date string is to be formatted and parsed. Applied only if type is "date" or "both". Valid values are "shortish", "short", "default", "medium", "long", and "full". Default value is "shortish".
hintBoth String Yes

Custom hint message to be used, instead of the default one when using type=both.

Parameters:

  • {0} the pattern the converter is expecting
hintDate String Yes

Custom hint message to be used, instead of the default one when using type=date.

Parameters:

  • {0} the pattern the converter is expecting
hintTime String Yes

Custom hint message to be used, instead of the default one when using type=time.

Parameters:

  • {0} the pattern the converter is expecting
locale java.util.Locale Yes Locale whose predefined styles for dates and times are used during formatting or parsing. If not specified or if null, the Locale returned by RequestContext.getFormattingLocale() will be used. If that is null, FacesContext.getViewRoot().getLocale() will be used.
messageDetailConvertBoth String Yes

Custom error message to be used, for creating detail part of faces message, for date-time based value that cannot be converted to date when type is set to 'both' and pattern is not set or is null.

Parameters:

  • {0} the label that identifies the component
  • {1} value entered by the user
  • {2} an example of the format the converter is expecting
Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
messageDetailConvertDate String Yes

Custom error message to be used, for creating detail part of faces message, for values that cannot be converted to date when the pattern / secondary pattern is set or when type is set to 'date' and pattern is not set or is null.

Parameters:

  • {0} the label that identifies the component
  • {1} value entered by the user
  • {2} an example of the format the converter is expecting
Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
messageDetailConvertTime String Yes

Custom error message to be used, for creating detail part of faces message, for time based value that cannot be converted to date when type is set to 'time', pattern is not set or is null

Parameters:

  • {0} the label that identifies the component
  • {1} value entered by the user
  • {2} an example of the format the converter is expecting
Please note: Parameter {1} which specifies the value entered by the user, should never be used in the message if the value is secure, like when secret=true on inputText.
pattern String Yes Custom formatting pattern which determines how the date/time string should be formatted and parsed. The syntax must conform to the rules specified by java.text.SimpleDateFormat.
secondaryPattern String Yes Second pattern, which will be used as a second attempt to parse a string if the primary pattern or styles fail, but is never used for formatting strings.
timeStyle String Yes Default Value: short

Predefined formatting style which determines how the time component of a date string is to be formatted and parsed. Applied only if type is "time" or "both". Valid values are "default", "short", "medium", "long", and "full". Default value is "short".
timeZone java.util.TimeZone Yes Time zone in which to interpret any time information in the date string. If not set here, picks this value from trinidad-config.xml configuration file. If not defined there, then it is defaulted to the value returned by TimeZone.getDefault(), which is usually server JDK timezone.
type String Yes Default Value: date

Specifies what contents the string value will be formatted to include, or parsed. Valid values are "date", "time", and "both". Default value is "date".