Rational Developer for System z

DateTime as STRING data

You can specify the dateTime format using a string of pattern letters.
If the dateTime object is CWF Packed Decimal, you can only use the symbols that are presented as numbers. For all other Physical Type options, you can use all symbols.

The count of pattern letters determines the format. Table 1 defines the letters that are reserved as pattern letters:

Table 1. DateTime formatting symbols
Symbol Meaning Presentation Example
a am or pm marker Text pm
d day in month Number 10
D day in year Number 189
e day in week (1-7) Number 2
E day in week Text Tuesday
F day in month Number 2 (and week in July)3
G era Text AD
h hour in am or pm (1-12) Number 12
H hour in day (0-24) Number 0
I parse as Date/Time (ISO8601)   See note 4.
k hour in day (1-24) Number 24
K hour in am or pm (0-11) Number 0
m minute in hour Number 30
M month in year Text and Number July and 07
w week in year Number 272
W week in month Number 2
s second in minute Number 55
S millisecond Number 978
T parse as time (ISO8601)   See note 4.
y year Number 19961
Y year: use with week in year only Number 19962
z TimeZone Text zzzz = Pacific Standard Time
Z time zone Text +50:30
' escape for text   'User text'
'' single quote within escaped text   'o"clock'
  1. Year is handled as a special case:
    • On output, if the count of y is 2, the year is truncated to 2 digits. For example, if yyyy produces 1997, yy produces 97.
    • On input, for 2 digit years the CWF message set property of Century Window is used to determine the century. For example, if Century Window is set to 53, year 97 is 1997, year 52 is 2052, and year 53 is 1953.
  2. The first day of a year does not usually fall on a week boundary, therefore dates expressed using week in year might refer to dates in neighboring years. For example, day 1 of week 1 in 2002 (2002 01 Monday) using format string YYYY ww EEEE is in fact 31st December 2001. If you use Y, the day of week (E) and week in year (w) are adjusted if necessary to indicate that the date falls in the previous year. If you use the y symbol, the adjustment is not done and unpredictable results could occur for dates around year end.

    For example, if the string 2002 01 Monday is formatted:

    • day 1 of week 1 in 2002 using format string YYYY ww EEEE is correctly interpreted as 31st December 2001
    • day 1 of week 1 in 2002 using format string yyyy ww EEEE is incorrectly interpreted as 30th December 2002

    Y should only be used in conjunction with w. If you specify Y without w, the year is ignored. For example, if you specify YYYY-mm-dd to format 1996-03-01 the result is 2002-03-01 because the year input is ignored and the current year is assumed.

  3. The 11th July 2001 is the second Wednesday in July and can be expressed as 2001 July Wednesday 2 using format string yyyy MMMM EEEE F. This is not the same as Wednesday in week 2 of July 2001, which is 4th July 2001.
    Note: The first and last week in a month might include days from neighboring months. For example, Tuesday 31st July 2001 could be expressed as Tuesday in week one of August 2001, which is 2001 08 1 Tuesday using format string yyyy MM W EEEE.
    Note: You can only express a time zone as an offset in hours and minutes from GMT ( +/-hh:mm ). The number of Z formatting symbols affects the output:
    • -Z (short form) produces -5
    • -ZZ (medium form) produces -05
    • -ZZZ (long form) produces -05:00
    • -ZZZZ (long form) produces GMT-05:00
  4. You can use the formatting symbol I (uppercase letter "i") to match any ISO8601 dateTime strings. Examples of these are shown in the ISO8601 dateTime examples below. An I should only be used alone.

    On input to a message flow, a format string of I allows any ISO8601 compliant dateTime to be parsed. On output from a message flow, the dateTime is always expressed in the fullest form yyyy-MM-dd'T'HH:mm:ss.SSS.

    If you use the T formatting symbol, format strings can be constructed to match ISO8601 dateTimes where T precedes the time portion of a dateTime entity.

The presentation of the dateTime object depends on what symbols you specify as follows:

  • Text. If you specify four or more of the symbols, the full form is presented. If you specify less than four, the short or abbreviated form, if it exists, is presented. For example, EEEE produces Monday, EEE produces Mon.
  • Number. Repeat the symbol to specify the minimum number of digits that you want. Shorter numbers are padded with zeros to this length. For example, if you specify m, the number 6 is presented. If you specify mm, the number 06 is presented. A year is a special case, see note 1 in the table.
  • Text and number. If you specify three or more symbols, text is displayed. If you specify less, the number is presented. For example, if you specify M, it produces 1. If you specify MM, it produces 01. If you specify MMM, it produces Jan. If you specify MMMM, it produces January.

    Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] are treated as quoted text. For example, characters like colon (:), comma (,), period (.), the number sign (hash or pound, #), the at sign (@) and space appear in the resulting time text even if they are not enclosed within single quotes.

Example

The following table shows examples of dateTime formats:
Table 2. 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

Year
   yyyy
Year and month
   yyyy-MM
Complete date
   yyyy-MM-dd
Complete date plus hours and minutes
   yyyy-MM-ddTHH:mm
Complete date plus hours, minutes, and seconds
   yyyy-MM-ddTHH:mm:ss
Complete date plus hours, minutes, seconds, and a decimal fraction of
a second
   yyyy-MM-ddTHH:mm:ss.S

You can create formatting strings that produce unpredictable results, so you must use these symbols with care. For example, if you specify dMyyyy, it is impossible to distinguish between day, month, and year. dMyyyy specifies that a minimum of one character represents the day, a minimum of one character represents the month, and four characters represent the year. Therefore 3111999 could be interpreted as 3/11/1999 and 31/1/1999.


Feedback