Format pattern elements for date/time values and numbers
Format patterns can be used to format date, time and number values.
System Formats for date/time values
To use the system date/time formats the following patterns constants are available:
Pattern
Constant
Description
short
systemShort
Short date/time format. e.G. 12/24/09 or 11:30 AM
medium
systemMedium
Medium date/time format. e.G. Dec 24, 2009 or 11:30:00 AM
long
systemLong
Long date/time format. e.G. Thursday, December 24, 2009 or 11:30:00 AM GMT+01:00
Note: The pattern is a case-insensitive string value while constant is a normal keyword.
Format pattern elements for date/time values:
yy
the last two digits of the year component
yyyy
all digits of the year component
M
the month component with single digit if month component has leading zero otherwise two digits
MM
the month component with two digits (first is zero if only one digit in month component)
MMM
the monthname in short representation (3 letters)
MMMM
the full monthname
d
the day component with single digit if day has leading zero otherwise two digits
dd
the day component with two digits (first is zero if only one digit in day component)
ddd
the dayname in short representation (3 letters)
dddd
the full dayname
h
12h representation with one digit if hours component has leading zero otherwise two digits
hh
12h representation with always two digits (first is zero if only one digit in hours component)
H
24h representation with one digit if hours component has leading zero otherwise two digits
HH
24h representation with always two digits (first is zero if only one digit in hours component)
m
the minutes conponent with one digit if minutes component has leading zero otherwise two digits
mm
the minutes component with two digits (first is zero if only one digit in minutes component)
s
the seconds conponent with one digit if seconds component has leading zero otherwise two digits
ss
the seconds component with two digits (first is zero if only one digit in seconds component)
t
single character indication if hours in the morning or evening
tt
double character indication if hours in the morning or evening
W
week of the month
ww
week of the year
Examples:
pattern
result
yyyy.MM.dd HH:mm:ss
2003.05.08 16:32
dddd d/M/yy hh:mm tt
Monday 4/8/03 4:33 p.m.
ddd, MMM d, 'yy
Mon, Aug 5 '03
yyMMddHHmmss
050804071245
Default formats for number values
To use the default formats for number the following patterns are available:
Pattern
Constant
Description
integer
integerFormat
Integer format, rounds off all decimal places. E.g. 100
decimal
decimalFormat
Fractional format which displays up to two decimal placed. E.g. 100.12
percent
percentFormat
Percentage format with 1 as reference. E.g. 1 = 100%, 0.45 = 45%
scientific
scientificFormat
Scientific format. Formats the number as mantissa and exponent. The mantissa will be between 1 and 10. E.g. 123 = 1.23E2
engineer
engineerFormat
Engineer format. Similar to the scientific format, but with mantissa between 1 and 1000 and an exponent which is a multiple of 3. E.g. 12345 = 12.345E3
Note: The pattern is a case-insensitive string value while constant is a normal keyword. This format is only valid for numbers, not for currency values.
Format pattern elements for number values:
#
the position of one digit. If pattern has more # than value digits than spaces will be inserted.
0
the position of one digit. If pattern has more # than value digits than zeros will be inserted.