学习札记二:格式项的语法{index[,alignment][:formatString]} (补)

当格式项对应的输出数据类型为DateTime时:
         formatString项                    {index:formatString}   结果
         (d) Short date:                     {0:d}                         2006-8-31
         (D) Long date:                     {0:D}                        2006年8月31日
         (t) Short time:                      {0:t}                          16:32
         (T) Long time:                     {0:T}                         16:32:46
         (f) Full date/short time:         {0:f}                          2006年8月31日 16:32
         (F) Full date/long time:         {0:F}                         2006年8月31日 16:32:46
         (g) General date/short time:   {0:g}                         2006-8-31 16:32
         (G) General date/long time:   {0:G}                        2006-8-31 16:32:46
             (default):                          {0} (default = 'G')      2006-8-31 16:32:46
         (M) Month:                          {0:M}                        8月31日
         (R) RFC1123:                      {0:R}                         Thu, 31 Aug 2006 16:32:46 GMT
         (s) Sortable:                         {0:s}                          2006-08-31T16:32:46
         (u) Universal sortable:           {0:u} (invariant)          2006-08-31 16:32:46Z(invariant)
         (U) Universal sortable:          {0:U}                         2006年8月31日 8:32:46
         (Y) Year:                              {0:Y}                         2006年8月

注:在windows操作系统中,通过"控件面板"→"区域和语言选项"→"区域选项"→"标准和格式"设置不同的国家语言,会出现不同的显示效果。“英文(美国)”与“英文(英国)”的日期显示方式也有所不同。

posted @ 2006-08-31 16:48  希冀  阅读(320)  评论(0编辑  收藏  举报