Menu

setDateTimeFormat

Creates a format that can be used with DateTime values. Note that Date and DateTime values are separate types as are their formats - despite both including date information, this command produces a format only for DateTime values. Use the setDateFormat command to produce a format for the less accurate time values.

Attributes

name

Required
Value type
EL-evaluated
No String Yes
Defines a name for the created format. If defined, other commands can choose to use this format by referring to it by this name.  

Leaving the created format nameless declares it as the default format for DateTime values. Any command that prints out a DateTime value will then use this format, unless the command specifies a named format for itself. If a default format for DateTime values has already been set, this new format will take its place as the default.
locale

Required
Value type
EL-evaluated
No String Yes
Specifies a locale for this format, affecting the formatting rules. The resolved String should be an ISO-639 language code and an ISO-3166 country code, joined by a hyphen or an underscore (eg. "en-US" or "en_US"). Alternatively the value may only specify the language code, but this may lead to unpredictable results if this format requires the country information.

If not defined, the format will follow the user's default locale.
pattern

Required
Value type
EL-evaluated
No String No
The value of this attribute is used as the pattern defining what kind of Strings this format will produce.

If not defined, a locale-dependent standard pattern will be used.

Examples

While DateTime values carry various time components, the pattern can be defined to omit any number of them. This format produces a typical clock display, with only the hour and minute shown:

<setDateTimeFormat name="clockDisplay" pattern="HH:mm">

A DateTime format may also ignore the time part entirely, producing output similar to Date values. All the patterns that work with setDateFormat also work with this command.

<setDateTimeFormat name="justDate" pattern="dd.MM.yyyy"> 

Comments

0 comments