zoukankan      html  css  js  c++  java
  • C# DateTime的ToString()方法的使用

    转载:https://www.cnblogs.com/webfans/p/3627868.html

    Console.WriteLine("ToShortDateString:" + DateTime.Now.ToShortDateString());
    Console.WriteLine("ToLongDateString:" + DateTime.Now.ToLongDateString());
    
    Console.WriteLine("ToShortTimeString:" + DateTime.Now.ToShortTimeString());
    Console.WriteLine("ToLongTimeString:" + DateTime.Now.ToLongTimeString());
    
    Console.WriteLine(DateTime.Now.ToString());
    Console.WriteLine(DateTime.Now.ToString("t"));
    
    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ms"));
    
    Console.WriteLine(DateTime.Now.ToString("d"));                    //格式: 2010-10-22
    Console.WriteLine(DateTime.Now.ToString("D"));                    //格式: 2010年10月22日
    
    Console.WriteLine(DateTime.Now.ToString("f"));                    //格式: 2010年10月22日 9:26
    Console.WriteLine(DateTime.Now.ToString("F"));                    //格式: 2010年10月22日 9:26:38
    
    Console.WriteLine(DateTime.Now.ToString("g"));                    //格式: 2010-10-22 9:26
    Console.WriteLine(DateTime.Now.ToString("G"));                    //格式: 2010-10-22 9:26:38
    
    Console.WriteLine(DateTime.Now.ToString("m"));                    //格式: 10月22日
    Console.WriteLine(DateTime.Now.ToString("r"));                    //格式: Fri, 22 Oct 2010 09:26:38 GMT
    Console.WriteLine(DateTime.Now.ToString("s"));                    //格式: 2010-10-22T09:26:38
    
    Console.WriteLine(DateTime.Now.ToString("t"));                    //格式: 9:26
    Console.WriteLine(DateTime.Now.ToString("T"));                    //格式: 9:26:38
    
    Console.WriteLine(DateTime.Now.ToString("u"));                    //格式: 2010-10-22 09:26:38Z
    Console.WriteLine(DateTime.Now.ToString("U"));                    //格式: 2010年10月22日 1:26:38
    
    Console.WriteLine(DateTime.Now.ToString("y"));                    //格式: 2010年10月
    Console.WriteLine(DateTime.Now.ToString("dddd"));                 //格式: 星期五
    Console.WriteLine(DateTime.Now.ToString("dddd, MMMM dd yyyy"));   //格式: 星期五, 十月 22 2010
    Console.WriteLine(DateTime.Now.ToString("ddd, MMM d yy"));        //格式: 五, 十月 22 10
    Console.WriteLine(DateTime.Now.ToString("dddd, MMMM dd"));        //格式: 星期五, 十月 22
    Console.WriteLine(DateTime.Now.ToString("M/yy"));                 //格式: 10-10
    Console.WriteLine(DateTime.Now.ToString("dd-MM-yy"));             //格式: 22-10-10
  • 相关阅读:
    SAP 标准成本滚算小记
    记一次SAP新业务开发项目
    让人头疼的关键用户
    SAP GUI个性化设置
    惊心动魄的SAP S4客户额度调整运动
    最新.net和Java调用SAP RFC中间件下载
    那些年我遇到的ERP顾问
    【SAP业务模式】之STO(二):系统配置
    SAP S4系统创建Customer和Vendor的BAPI
    【SAP S/4 1511之变】:主数据之变
  • 原文地址:https://www.cnblogs.com/uftwkb24/p/10213189.html
Copyright © 2011-2022 走看看