setDateTimeParser
Creates a parser that can make DateTime values out of Strings.
Parsers can be used in the logic with the set command, and in document content with the content logic attribute.
Attributes
name | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | String | Yes |
Defines a name for the created parser. Other commands can choose to use this parser by referring to it by this name. |
locale | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Specifies a locale for this parser, 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 (e.g. "en-US" or "en_US"). Alternatively the value may only specify the language code, but this may lead to unpredictable results if this parser requires the country information. If not defined, the parser 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 this parser uses to read Strings and form them into DateTime values. If not defined, a locale-dependent standard pattern will be used. |
timeZone | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | Yes |
Specifies the time zone that the DateTime values produced by this parser are on. Use time zone names like "Europe/London", "America/New_York" or "Etc/GMT+2" for example. If not defined, the active user's time zone is used. |
Examples
A String defining a moment at a morning such as "06:52:12" could be parsed into a DateTime with a parser like this:
<setDateTimeParser name="timeParser" pattern="HH:mm:ss">
The time components that the parsed String do not define default to the components of the "base" DateTime value, time 00:00:00 in 1st of January, 1970. So a DateTime parsed out of the morning moment String would report its seconds as 52 as defined in the String, but its year as 1970.