Summary

Tag Name:af:convertDateTime>
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 trinidad-config.xml configuration file. If timeZone is not set on the converter, then timezone will be defaulted to the value set in trinidad-config.xml configuration file. If it is not set in the configuration file, then it will be defaulted to the value returned by TimeZone.getDefault(), usually the server's JVM timezone.

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

  • A converter with associated pattern 'MMM' for month, when attached to any value holder, will accept values with month specified in the form 'MM' or 'M' as valid.
  • Allows use of separators '-' or '.' or '/' irrespective of the separator specified in the associated pattern.
  • The leniency is applicable to both 'pattern' and 'secondaryPattern'.

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:

  • When timezone is specified to have a long display, e.g.'timeStyle=full' or a pattern with 'zzzz'. Instead of a long descriptive string, e.g. "Pacific Standard Time", the timezone will be displayed in the General Timezone format (GMT +/- offset) or RFC-822 timezones.

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.

Code Example(s)

<af:inputText id="mdf5" value="2004/09/06" label="Date">
  <af:convertDateTime pattern="yyyy/M/d" secondaryPattern="d/M/yyyy" />
</af:inputText>

Attributes

Name Type Supports EL? Description
dateStyleStringYes 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".
disabledbooleanYes Default Value: false

Whether the converter should be disabled, default to false.
hintBothStringYes

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

Parameters:

  • {0} the pattern the converter is expecting
hintDateStringYes

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

Parameters:

  • {0} the pattern the converter is expecting
hintTimeStringYes

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

Parameters:

  • {0} the pattern the converter is expecting
localejava.util.LocaleYes 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.
messageDetailConvertBothStringYes

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.
messageDetailConvertDateStringYes

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.
messageDetailConvertTimeStringYes

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.
patternStringYes 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.
secondaryPatternStringYes 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.
timeStyleStringYes 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".
timeZonejava.util.TimeZoneYes 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.
typeStringYes 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".