The datetimeStyle used in formatting InternationalTokens tokens is shown below:

"short"

Completely numeric, such as 12.13.52 or 3:30pm.

"medium"

Longer, such as Jan 12, 1952.

"long"

Longer, such as January 12, 1952 or 3:30:32pm.

"full"

Complete, such as Tuesday, April 12, 1952 AD or 3:30:42pm PST.

dateFormatPattern

see below

dateFormatPattern

This allows you to specify the time format to use as a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as follows:

Symbol

Meaning

Presentation

Example

G

era designator

(Text)

AD

y

year

(Number)

1996

M

month in year

(Text & Number)

July & 07

d

day in month

(Number)

10

h

hour in am/p.m. (1~12)

(Number)

12

H

hour in day (0~23)

(Number)

0

m

minute in hour

(Number)

30

s

second in minute

(Number)

55

S

millisecond

(Number)

978

E

day in week

(Text)

Tuesday

D

day in year

(Number)

189

F

day of week in month

(Number)

2 (2nd Wed in July)

w

week in year

(Number)

27

W

week in month

(Number)

2

a

am/p.m. marker

(Text)

p.m.

k

hour in day (1~24)

(Number)

24

K

hour in am/p.m. (0~11)

(Number)

0

z

time zone

(Text)

Pacific Standard Time

'

escape for text

(Delimiter)

 

"

single quote

(Literal)

'

The number of pattern symbols used determines the format of the output. For symbols that produce text, 4 or more symbols specify the use of the full form, less than 4 symbols the use of the short or abbreviated form if one exists. For symbols that produce numbers, the number of symbols specifies the minimum number of digits. Shorter numbers are zero-padded to this amount. The year is handled differently, that is, if the number of symbols is 2, the year will be truncated to 2 digits. For symbols that can produce either text or numbers, 3 or more symbols specifies the use of the text, and less than 3 the use of the number.

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even if they are not embraced within single quotes.

A pattern containing any invalid pattern letter will cause the formatting to be ignored.

Below are some examples using the US locale:

Format Pattern

Result

"yyyy.MM.dd G 'at' hh:mm:ss z"

1996.07.10 AD at 15:08:56 PDT

"EEE, MMM d, ''yy"

Wed, July 10, '96

"h:mm a"

12:08 p.m.

"hh 'o''clock' a, zzzz"

12 o'clock p.m., Pacific Daylight Time

"K:mm a, z"

0:00 p.m., PST

"yyyyy.MMMMM.dd GGG hh:mm aaa"

1996.July.10 AD 12:08 p.m.

Comment on this topic

Topic ID: 150046