Formatting can be done by using string. The format method is executed directly or by using the Xx.tostring ("") method. Formatting rules are not too good to remember, this article through Simple CI, can help you remember these rules
1. Number format
The rules are simple. The type of the format can be optionally followed by a number to indicate the number of decimal places to retain.
The letters are just a few: C, D, E, F, G, N, P, R, X case is universal
2. DateTime format
2013-05-18 13:09:24.211 +8:00
Year is Y:
One Y-year single-digit
YY year after two digits
Three digits after yyy year
YYYY four-bit year
YYYYY four-digit year before plus 0
Large m table month, less than 10 without leading 0
MM table month, less than October to add a leading 0
Three m month name, to be remembered in short order
Four m month name, to use the full name can not forget
A d indicates the number, No. 0 before 10th.
DD says it's a number, plus 0 before 10th.
DDD means the day of the week, the name is abbreviated to remember
Dddd said the day of the week, to use the full name can not forget
Lowercase h table hours, 12 can not be forgotten
An h cannot be preceded by 0, two h if necessary leading 0
Size h table hour, 24 into the system to remember
An h cannot be preceded by 0, two h if necessary leading 0
lowercase m table minutes, one without leading 0, two if necessary leading 0
Lowercase s represents seconds, one without leading 0, two if necessary leading 0
F means one-tenth seconds
FF represents percent of seconds
FFF represents the number of milliseconds
FFFF represents very one of the milliseconds
The analogy to 7f
Uppercase lowercase has a difference
If it is 0, uppercase ignores lowercase has
There are two other less common
GG means on the afternoon
K, z means the time zone