扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Microsoft 来源:CSDN 2007年9月28日
关键字: 格式化
Specifier |
Type |
Format |
Input |
Output |
---|---|---|---|---|
c |
Currency |
{ 0:c} |
250.25 |
$250.25 |
-250.25 |
-$250.25 | |||
d |
Decimal (whole number) |
{ 0:d} |
250 |
250 |
-250 |
-250 | |||
e |
Scientific |
{ 0:e} |
3.14 |
3.140000e+000 |
-3.14 |
-3.140000e+000 | |||
f |
Fixed point |
{ 0:f} |
3.14 |
3.14 |
-3.14 |
-3.14 | |||
g |
General |
{ 0:g} |
3.14 |
3.14 |
-3.14 |
-3.14 | |||
n |
Number with commas for thousands |
{ 0:n} |
25000 |
25,000 |
-25000 |
-25,000 | |||
p |
Percent |
{ 0:p} |
.25 |
25.00% |
{ 0,2:p} |
.25555 |
25.56% | ||
X |
Uppercase hexadecimal |
{ 0:X} |
15 |
F |
x |
Lowercase hexadecimal |
{ 0:x} |
15 |
Specifier |
Type |
Format |
Input |
Output |
---|---|---|---|---|
0 |
Zero placeholder |
{ 0:00.0000} |
3.14 |
3.1400 |
# |
Digit placeholder |
{ 0:(#).##} |
3.14 |
(3).14 |
. |
Decimal point |
{ 0:0.0} |
3.14 |
3.1 |
, |
Thousand separator |
{ 0:0,0} |
2500.25 |
2,500 |
,. |
Number scaling |
{ 0:0,.} |
2000 |
2 (Note: Scales by 1000) |
% |
Percent |
{ 0:0%} |
25 |
2500% Multiplies by 100 and adds percent sign |
; |
Group separator |
{Positive-Format};{ Negative-Format} ;{Zero-format} |
Specifier |
Description |
Format |
Result Using System.DateTime.Now |
---|---|---|---|
d |
Short date |
{ 0:d} |
4/17/2004 |
D |
Long date |
{ 0:D} |
April 17, 2004 |
t |
Short time |
{ 0:t} |
11:50 AM |
T |
Long time |
{ 0:T} |
11:50:30: AM |
f |
Full date and time |
{ 0:f} |
April 17, 2004 11:51 AM |
F |
Long full date and time |
{ 0:F} |
April 17, 2004 11:51:45 AM |
g |
Default date and time |
{ 0:g} |
4/17/2004 11:53 AM |
G |
Long default date and time |
{ 0:G} |
4/17/2004 11:53:45 AM |
M or m |
Month day |
{ 0:M} |
April 17 |
R or r |
RFC1123 date string |
{ 0:r} |
Sat, 17 Apr 2004 11:55:17 GMT |
s |
Sortable date string ISO 8601 |
{ 0:s} |
2004-04-17T11:56:22 |
u |
Universal sortable date pattern |
{ 0:u} |
2004-04-17 11:58:11Z |
U |
Universal sortable full date pattern |
{ 0:U} |
Saturday, April 17, 2004 3:58:32 PM |
Y or y |
Year month pattern |
{ 0:Y} |
Specifier |
Description |
Format | |
---|---|---|---|
d |
Displays the day of the week as a number |
{ 0:d} | |
dd |
Displays the day of the month as a leading zero integer |
{ 0:dd} | |
ddd |
Displays the abbreviated day of the week |
{ 0:ddd} | |
dddd |
Displays the full name of the day of the week |
{ 0:dddd} | |
f,ff,fff,ffff... |
Displays seconds fractions in one or more digits |
{ 0:f} or { 0:ff} | |
g or gg |
Displays the era, such as B.C. or A.D. |
||
h |
Displays the hour from 112 |
{ 0:h} | |
hh |
Displays the hour from 112 with leading zero |
{ 0:hh} | |
H |
Displays the hour in military format 023 |
{ 0:H} | |
HH |
Displays the hour in military format 023 with leading zero for single-digit hours |
{ 0:HH} | |
m |
Displays the minute as an integer |
{ 0:m} | |
mm |
Displays the minute as an integer with leading zero for single-digit minute values |
{ 0:mm} | |
M |
Displays the month as an integer |
{ 0:M} | |
MM |
Displays the month as an integer with leading zero for single-digit month values |
{ 0:MM} | |
MMM |
Displays the abbreviated month name |
{ 0:MMM} | |
MMMM |
Displays the full name of the month |
{ 0:MMMM} | |
s |
Displays the seconds as a integer |
{ 0:s} | |
ss |
Displays the seconds as an integer with a leading zero for single-digit second values |
{ 0:ss} | |
t |
Displays the first character of A.M. or P.M. |
{ 0:t} | |
tt |
Displays the full A.M. or P.M. |
{ 0:tt} | |
y |
Displays two-digit year, with no preceding 0 for values 09. |
{ 0:y} | |
yy |
Displays two-digit year |
{ 0:yy} | |
yyyy |
Displays four-digit year |
{ 0:yyyy} | |
zz |
Displays the time zone offset |
{ 0:zz} | |
: |
Time separator |
{ 0:hh:mm:tt} | |
/ |
Date separator |
Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1624486
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者