Please enable JavaScript to view this site.

CWT User Interface Design Handbook

Format specifier

These formatting characters can be combined to create the required formatting.

Example: Use the format string ”d MMM yyyy” to display the date in the format “1 Apr 2009”.

/

The date separator that is used to differentiate years, months, and days.

Must be preceded by the backslash character.

:

The time separator that is used to differentiate hours, minutes, and seconds.

\c

The escape character. Displays the character "c" as a literal when that character is preceded by the escape character (\). To insert the backslash character itself in the result string, use two escape characters ("\\").

Any other character

Any other character is copied to the result string, and does not affect formatting.

d

Represents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero.

dd

Represents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero.

ddd

Represents the abbreviated name of the day of the week.

dddd (plus any number of additional "d" specifiers)

Represents the full name of the day of the week.

h

Represents the hour as a number from 1 through 12, that is, the hour as represented by a 12-hour clock that counts the whole hours since midnight or noon. Consequently, a particular hour after midnight is indistinguishable from the same hour after noon. The hour is not rounded, and a single-digit hour is formatted without a leading zero. For example, given a time of 5:43, this format specifier displays "5".

H

Represents the hour as a number from 0 through 23, that is, the hour as represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted without a leading zero.

hh, hh (plus any number of additional "h" specifiers)

Represents the hour as a number from 01 through 12, that is, the hour as represented by a 12-hour clock that counts the whole hours since midnight or noon. Consequently, a particular hour after midnight is indistinguishable from the same hour after noon. The hour is not rounded, and a single-digit hour is formatted with a leading zero. For example, given a time of 5:43, this format specifier displays "05".

HH, HH (plus any number of additional "H" specifiers)

Represents the hour as a number from 00 through 23, that is, the hour as represented by a zero-based 24-hour clock that counts the hours since midnight. A single-digit hour is formatted with a leading zero.

m

Represents the minute as a number from 0 through 59. The minute represents whole minutes passed since the last hour. A single-digit minute is formatted without a leading zero.

M

Represents the month as a number from 1 through 12. A single-digit month is formatted without a leading zero.

MM

Represents the month as a number from 01 through 12. A single-digit month is formatted with a leading zero.

mm, mm (plus any number of additional "m" specifiers)

Represents the minute as a number from 00 through 59. The minute represents whole minutes passed since the last hour. A single-digit minute is formatted with a leading zero.

MMM

Represents the abbreviated name of the month

MMMM

Represents the full name of the month

t

Represents the first character of the A.M./P.M. designator. The A.M. designator is used if the hour in the time being formatted is less than 12; otherwise, the P.M. designator is used.

tt, tt (plus any number of additional "t" specifiers)

Represents the A.M./P.M. designator. The A.M. designator is used if the hour in the time being formatted is less than 12; otherwise, the P.M. designator is used.

y

Represents the year as at most a two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the year has fewer than two digits, the number is formatted without a leading zero.

yy

Represents the year as a two-digit number. If the year has more than two digits, only the two low-order digits appear in the result. If the year has fewer than two digits, the number is padded with leading zeroes to achieve two digits.

yyy

Represents the year as a three-digit number. If the year has more than three digits, only the three low-order digits appear in the result. If the year has fewer than three digits, the number is padded with leading zeroes to achieve three digits.

Note that for the Thai Buddhist calendar, which can have five-digit years, this format specifier displays all five digits.

yyyy

Represents the year as a four-digit number. If the year has more than four digits, only the four low-order digits appear in the result. If the year has fewer than four digits, the number is padded with leading zeroes to achieve four digits.

Note that for the Thai Buddhist calendar, which can have five-digit years, this format specifier renders all five digits.

yyyyy (plus any number of additional "y" specifiers)

Represents the year as a five-digit number. If the year has more than five digits, only the five low-order digits appear in the result. If the year has fewer than five digits, the number is padded with leading zeroes to achieve five digits.

If there are additional "y" specifiers, the number is padded with as many leading zeroes as necessary to achieve the number of "y" specifiers.