Date and Time Functions
There are some functions in the XPath formula builder using which you can parse or format strings that represent dates and times. These functions are:
- format-dateTime(format, dateTime)
- format-date(format, date)
- format-time(format, time)
- parse-dateTime(format, string)
- parse-date(format, string)
- parse-time(format, string)
The format parameter of these functions is based on the format patterns available for the java.text.SimpleDateFormat Java class. In the format parameter, unquoted alphabetic characters from A to Z and a to z represent the components of the date or time string. You can include non-pattern alphabetic characters in the string by quoting the text with single quotes. To include a single quote, use ’’. Table 43 describes the alphabetic characters and their associated presentation in a date or time string.
Letter | Description | Example |
---|---|---|
G |
Era
Four or more Gs return the full name of the era. |
AD |
y |
year
Two ys return two-digit year. |
2003; 03 |
M |
Month in year
Three or more Ms return text name. |
August; Aug; 08 |
w |
Week in year | 48 |
W |
Week in month | 3 |
D |
Day in year | 254 |
d |
Day in month | 28 |
F |
Day of week in month | 3 |
E |
Day in week
Four or more Es return the full name of the weekday. |
Friday; Fri |
a |
AM/PM marker
Four or more as return the full name. |
AM |
H |
Hour in day (0-23) | 23 |
k |
Hour in day (1-24) | 1 |
K |
Hour in AM/PM (0-11) | 11 |
h |
Hour in AM/PM (1-12) | 1 |
m |
Minute in hour | 59 |
s |
Second in minute | 48 |
S |
Millisecond | 456 |
z |
Time zone represented as a GMT offset. | GMT-08:00 |
Z |
RFC 822 four-digit time zone format | -0800 |
all other letters | Reserved |
For any format pattern letter that returns a numeric value (for example, w, h, and m), the number of letters in the format pattern represents the minimum number of digits. For formatting functions, if the date or time has fewer digits than the number of pattern letters, the output is padded with zeros. For parsing functions, when the date or time has fewer digits than the number of characters in the format pattern, the extra characters are ignored, unless they are needed to determine the boundaries of adjacent fields.
Table 44 illustrates some example date and time format patterns and the resulting string.