zoukankan      html  css  js  c++  java
  • DateTime.ToLongDateString

    //引入命名空间
    using System;
    using System.Globalization;
    
    class Sample 
    {
        public static void Main() 
        {
            // Initialize a DateTime object.
            Console.WriteLine("Initialize the DateTime object to May 16, 2001 3:02:15 AM.
    ");
            DateTime dateAndTime = new System.DateTime(2001, 5, 16, 3, 2, 15);
    
            // Display the name of the current culture.
            Console.WriteLine($"Current culture: "{CultureInfo.CurrentCulture.Name}"
    ");
            var dtfi = CultureInfo.CurrentCulture.DateTimeFormat;
    
            // Display the long date pattern and string.
            Console.WriteLine($"Long date pattern: "{dtfi.LongDatePattern}"");
            Console.WriteLine($"Long date string:  "{dateAndTime.ToLongDateString()}"
    ");
    
            // Display the long time pattern and string.
            Console.WriteLine($"Long time pattern: "{dtfi.LongTimePattern}"");
            Console.WriteLine($"Long time string:  "{dateAndTime.ToLongTimeString()}"
    ");
    
            // Display the short date pattern and string.
            Console.WriteLine($"Short date pattern: "{dtfi.ShortDatePattern}"");
            Console.WriteLine($"Short date string:  "{dateAndTime.ToShortDateString()}"
    ");
    
            // Display the short time pattern and string.
            Console.WriteLine($"Short time pattern: "{dtfi.ShortTimePattern}"");
            Console.WriteLine($"Short time string:  "{dateAndTime.ToShortTimeString()}"
    ");
        }
    }

    Current culture: "en-US"
    
    Long date pattern: "dddd, MMMM d, yyyy"
    Long date string:  "Wednesday, May 16, 2001"
    
    Long time pattern: "h:mm:ss tt"
    Long time string:  "3:02:15 AM"
    
    Short date pattern: "M/d/yyyy"
    Short date string:  "5/16/2001"
    
    Short time pattern: "h:mm tt"
    Short time string:  "3:02 AM"

    转载自:https://vimsky.com/examples/detail/csharp-method-system.datetime.tolongdatestring.html
  • 相关阅读:
    YTU 1002: Home Work
    C++拷贝构造函数(深拷贝,浅拷贝)
    深入探讨this指针
    C++中关于strtok()函数的用法
    STL笔记之【map之移除元素】
    进程结束后,进程的所有内存都将被释放,包括堆上的内存泄露的内存。
    数组指针和指针数组的区别
    sizeof()用法汇总
    文件描述符和文件指针的区别
    字符集、字符编码、XML中的中文编码
  • 原文地址:https://www.cnblogs.com/zsznh/p/14784866.html
Copyright © 2011-2022 走看看