Node:Format, Next:, Previous:timestamp, Up:timestamp



Format

The pattern string specifies how the time should be formatted. It is a subset of the format used by the java.text.SimpleDateFormat class in Java.

In the pattern, unquoted alphabetical letters ('A' to 'Z' and 'a' to 'z') are processed as a time component. All other characters are literals, and are copied to the output unchanged. Text inside single-quotes (') are also treated as literals. To output a single-quote, use two consecutive single-quotes.

The recognised time components are shown below. All other letters are reserved, and should not be used. (For debugging purposes, they generate a # in the output).


G
era designator (always AD)
y
year (just the century if the width is 2 or less)
M
month (1-12)
D
day in year (1-366)
d
day in month (1-31)
H
Hour in day 0-23
k
Hour in day 1-24
K
Hour in am/pm 0-11
h
Hour in am/pm 1-12 (commonly used with am/pm)
m
Minute in hour (0-59)
s
Seconds in minute (0-59)
S
Milliseconds (this will always be zero)
a
"AM" or "PM"
z
timezone UTC or +-dd:dd
Z
RFC822 format timezone +-dddd

The number of times a letter is repeated determines the minimum width of that field. Numeric fields are left padded with zeros to meet the minimum width. The width has no effect if the value is already equal to or greater than the minimum width. The width also has no effect on non-numeric values (namely G, a, z and Z).

These examples are for 5:29:59pm on the 30th of June, 2002:

"yyyy-M-d"                  => 2002-06-30
"yyyy-MM-dd'T'HH:mm:ss"     => 2002-06-30T17:29:59
"yyyy.M.d HH:mm"            => 2002.6.30 17:29
"yyyy.MM.dd hh:mma"         => 2002.06.30 05:29PM
"d/m/yy h:mm:ssa"           => 30/6/02 5:29:59PM