This section gives information on how you can specify the dateTime format using a string of pattern letters.
When you are converting a date or time into a string, a format pattern can be applied that directs the conversion. This would apply if you were formatting from a date or time into a string or parsing a string into a date or time.
During the formatting (for example, a dateTime to a string) a pattern or a set of tokens is replaced with their equivalent source. Figure 1 gives a representation of how this is applied.
When a string is parsed (for example, converting it to a dateTime), the pattern or set of tokens are used to determine which part of the target dateTime is represented by which part of the string. Figure 2 gives a representation of how this is applied.
The expression pattern is defined by:
.--------------.
| .- -. |
V V | |
>------+-symbol-+->
'-string-'
The following table lists the allowable characters that can be used in a pattern for formatting or parsing strings in relation to a dateTime.
Symbol | Meaning | Presentation | Examples |
---|---|---|---|
a | am or pm marker | Text | Input am, AM, pm, PM. Output AM or PM |
d | day in month (1-31) | Number | 1, 20 |
dd | day in month (01-31) | Number | 01, 31 |
D | day in year (1-366) | Number | 3, 80, 100 |
DD | day in year (01-366) | Number | 03, 80, 366 |
DDD | day in year (001-366) | Number | 003 |
e | day in week (1-7) | Number | 26 |
EEE | day in week | Text | Tue |
EEEE | day in week | Text | Tuesday |
F | day of week in month (1-5) | Number | 2 (for second Wednesday in July)3 |
G | Era | Text | BC or AD |
h | hour in am or pm (1-12) | Number | 6 |
hh | hour in am or pm (01-12) | Number | 06 |
H | hour of day in 24 hour form (0-23) | Number | 77 |
HH | hour of day in 24 hour form (00-23) | Number | 077 |
I | ISO8601 Date/Time (up to yyyy-MM-dd'T'HH:mm:ss. SSSZZZ) | text | 2004-10-07T12:06:56.568+01:00 5 |
IU | ISO8601 Date/Time (as above, but ZZZ with output "Z" if the timezone is +00:00) | text | 2004-10-07T12:06:56.568+01:00, 2003-12 -15T15:42:12.000Z 5 |
k | hour of day in 24 hour form (1-24) | Number | 87 |
k | hour of day in 24 hour form (01-24) | Number | 087 |
K | hour in am or pm (0-11) | Number | 9 |
KK | hour in am or pm (00-11) | Number | 09 |
m | minute | Number | 4 |
mm | minute | Number | 04 |
M | numeric month | Number | 5, 12 |
MM | numeric month | Number | 05, 12 |
MMM | named month | Text | Jan, Feb |
MMMM | named month | Text | January, February |
s | seconds | Number | 5 |
ss | seconds | Number | 05 |
S | decisecond | Number | 78 |
SS | centisecond | Number | 708 |
SSS | millisecond | Number | 7008 |
SSSS | 1/10,000 th seconds | Number | 70008 |
SSSSS | 1/100,000 th seconds | Number | 700008 |
SSSSSS | 1/1,000,000 th seconds | Number | 7000008 |
T | ISO8601 Time (up to HH:mm:ss.SSSZZZ) | text | 12:06:56.568+01:005 |
TU | ISO8601 Time (as above, but a timezone of +00:00 is replaced with 'Z') | text | 12:06:56.568+01:00, 15:42:12.000Z5 |
w | week in year | Number | 7, 532 |
ww | week in year | Number | 07, 532 |
W | week in month | Number | 24 |
yy | year | Number | 961 |
yyyy | year | Number | 19961 |
YY | year: use with week in year only | Number | 962 |
YYYY | year: use with week in year only | Number | 19962 |
zzz | time zone (abbreviated name) | Text | gmt |
zzzz | time zone (full name) | Text | Greenwich Mean Time |
Z | time zone (+/-n) | Text | +3 |
ZZ | time zone (+/-nn) | Text | +03 |
ZZZ | time zone (+/-nn:nn) | Text | +03:00 |
ZZZU | time zone (as ZZZ, "+00:00" is replaced by "Z") | Text | +03:00, Z |
ZZZZ | time zone (GMT+/-nn:nn) | Text | GMT+03:00 |
ZZZZZ | time zone (as ZZZ, but no colon) (+/-nnnn) | Text | +0300 |
' | escape for text | 'User text' | |
'' | (two single quotes) single quote within escaped text | 'o''clock' |
The presentation of the dateTime object depends on what symbols you specify as follows:
If you use the y symbol, the adjustment is not done and unpredictable results could occur for dates around the end of the year. For example, if the string "2005 01 Monday" is formatted:
If your dateTime values are compliant with the ISO8601:2000 'Representation of dates and times' standard, you should consider whether it is possible to use the formatting symbols I and T. These match a subset of the ISO8601 standard, specifically:
These symbols should only be used on their own.
On output, following form will be applied depending on the logical datatype:
Logical MRM Datatype | Logical ESQL Datatype | Output Form |
---|---|---|
xsd:dateTime | TIMESTAMP or GMTTIMESTAMP | yyyy-MM-dd'T'HH:mm:ss.SSSZZZ |
xsd:date | DATE | yyyy-MM-dd |
xsd:gYear | INTERVAL | yyyy |
xsd:gYearMonth | INTERVAL | yyyy-MM |
xsd:gMonth | INTERVAL | --MM |
xsd:gmonthDay | INTERVAL | --MM-dd |
xsd:gDay | INTERVAL | ---dd |
xsd:time | TIME / GMTTIME | 'T'HH:mm:ss.SSSZZZ |
An element or attribute of logical type xsd:dateTime or xsd:time that contains a dateTime as a string can specify Consolidated Universal Time (UTC) by using either the Z character or time zone +00:00. On input the MRM parser remembers the UTC format of such elements and attributes. On output you can specify whether Z or +00:00 should appear by using the dateTime format property of the element or attribute. Alternatively you can preserve the input UTC format by checking message set property Use input UTC format on output. If this property is checked, then the UTC format will be preserved into the output message and will override that implied by the dateTime format property.
The following table shows a few examples of dateTime formats:
Format pattern | Result |
---|---|
"yyyy.MM.dd'at'HH:mm:ss ZZZ" | 1996.07.10 at 15:08:56 -05:00 |
EEE, MMM d, "yy" | Wed, July 10, '96 |
"h:mm a" | 8:08 PM |
"hh 'o''clock' a, ZZZZ" | 09 o'clock AM, GMT+09:00 |
"K:mm a, ZZZ" | 9:34 AM, -05:00 |
"yyyy.MMMMM.dd hh:mm aaa" | 1996.July.10 12:08 PM |
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ak05616_ |