zoukankan      html  css  js  c++  java
  • DateTime.ToString内容写法

     1using System;
     2using System.Globalization; 
     3
     4public class MainClass 
     5   public static void Main(string[] args)  {
     6       DateTime dt = DateTime.Now;
     7       String[] format = {
     8           "d""D",
     9           "f""F",
    10           "g""G",
    11           "m",
    12           "r",
    13           "s",
    14           "t""T",
    15           "u""U",
    16           "y",
    17           "dddd, MMMM dd yyyy",
    18           "ddd, MMM d \"'\"yy",
    19           "dddd, MMMM dd",
    20           "M/yy",
    21           "dd-MM-yy",
    22       }
    ;
    23       String date;
    24       for (int i = 0; i < format.Length; i++{
    25           date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
    26           Console.WriteLine(String.Concat(format[i], " :" , date));
    27       }

    28 
    29  /** Output.
    30   *
    31   * d :08/17/2000
    32   * D :Thursday, August 17, 2000
    33   * f :Thursday, August 17, 2000 16:32
    34   * F :Thursday, August 17, 2000 16:32:32
    35   * g :08/17/2000 16:32
    36   * G :08/17/2000 16:32:32
    37   * m :August 17
    38   * r :Thu, 17 Aug 2000 23:32:32 GMT
    39   * s :2000-08-17T16:32:32
    40   * t :16:32
    41   * T :16:32:32
    42   * u :2000-08-17 23:32:32Z
    43   * U :Thursday, August 17, 2000 23:32:32
    44   * y :August, 2000
    45   * dddd, MMMM dd yyyy :Thursday, August 17 2000
    46   * ddd, MMM d "'"yy :Thu, Aug 17 '00
    47   * dddd, MMMM dd :Thursday, August 17
    48   * M/yy :8/00
    49   * dd-MM-yy :17-08-00
    50   */

    51   }

    52}

    53
  • 相关阅读:
    基础最短路(模板 bellman_ford)
    UVA-12304 Race(递推)
    How do you add?(递推)
    Coconuts, Revisited(递推+枚举+模拟)
    UVA-10726 Coco Monkey(递推)
    UVA-10995 Educational Journey
    UVA-10339 Watching Watches
    【React】377- 实现 React 中的状态自动保存
    【JS】376- Axios 使用指南
    【Nodejs】375- 如何加快 Node.js 应用的启动速度
  • 原文地址:https://www.cnblogs.com/yuxiang9999/p/323569.html
Copyright © 2011-2022 走看看