Mapping framework uses java.text.SimpleDateFormatclass to work with dates.
Date and time formats are specified by date and time pattern strings. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. ''represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.
The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved):
|
Letter |
DateorTimeComponent |
Presentation |
Examples |
|
G |
Eradesignator |
AD |
|
|
y |
Year |
1996; 96 |
|
|
M |
Monthinyear |
July; Jul; 07 |
|
|
w |
Weekinyear |
27 |
|
|
W |
Weekinmonth |
2 |
|
|
D |
Dayinyear |
189 |
|
|
d |
Dayinmonth |
10 |
|
|
F |
Day of week in month |
2 |
|
|
E |
Dayinweek |
Tuesday; Tue |
|
|
a |
Am/pmmarker |
PM |
|
|
H |
Hourinday (0-23) |
0 |
|
|
k |
Hourinday (1-24) |
24 |
|
|
K |
Hourinam/pm (0-11) |
0 |
|
|
h |
Hourinam/pm (1-12) |
12 |
|
|
m |
Minuteinhour |
30 |
|
|
s |
Secondinminute |
55 |
|
|
S |
Millisecond |
978 |
|
|
z |
Timezone |
Pacific Standard Time; PST; GMT-08:00 |
|
|
Z |
Timezone |
-0800 |
Table 42.Letter patterns
Pattern letters are usually repeated, as their number determines the exact presentation:
For parsing, if the number of pattern letters is more than 2, the year is interpreted literally, regardless of the number of digits. So using the pattern "MM/dd/yyyy", "01/11/12" parses to Jan 11, 12 A.D.
The following examples show how date and time patterns are interpreted in the U.S. locale. The given date and time are 2001-07-04 12:08:56 local time in the U.S. Pacific Time time zone.
|
DateandTimePattern |
Result |
|
"yyyy.MM.dd G 'at' HH:mm:ss z" |
2001.07.04 AD at 12:08:56 PDT |
|
"EEE, MMM d, ''yy" |
Wed, Jul 4, '01 |
|
"h:mm a" |
12:08 PM |
|
"hh 'o''clock' a, zzzz" |
12 o'clock PM, Pacific Daylight Time |
|
"K:mm a, z" |
0:08 PM, PDT |
|
"yyyyy.MMMMM.dd GGG hh:mmaaa" |
02001.July.04 AD 12:08 PM |
|
"EEE, dMMMyyyyHH:mm:ssZ" |
Wed, 4 Jul 2001 12:08:56 -0700 |
|
"yyMMddHHmmssZ" |
010704120856-0700 |
Table 43.Patterns usage examples