本文整理汇总了VB.NET中System.DateTime.ToLongDateString方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DateTime.ToLongDateString方法的具体用法?VB.NET DateTime.ToLongDateString怎么用?VB.NET DateTime.ToLongDateString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToLongDateString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Globalization
Module Example
Public Sub Main()
' Initialize a DateTime object.
Console.WriteLine($"Initialize the DateTime object to May 16, 2001 3:02:15 AM.{vbCrLf}")
Dim dateAndTime As New DateTime(2001, 5, 16, 3, 2, 15)
' Display the name of the current culture.
Console.WriteLine($"Current culture: ""{CultureInfo.CurrentCulture.Name}""{vbCrLf}")
Dim 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()}{vbCrLf}")
' Display the long time pattern and string.
Console.WriteLine($"Long time pattern: ""{0}""", dtfi.LongTimePattern)
Console.WriteLine($"Long time string: ""{dateAndTime.ToLongTimeString()}{vbCrLf}")
' Display the short date pattern and string.
Console.WriteLine($"Short date pattern: ""{dtfi.ShortDatePattern}""")
Console.WriteLine($"Short date string: ""{dateAndTime.ToShortDateString()}{vbCrLf}")
' Display the short time pattern and string.
Console.WriteLine($"Short time pattern: ""{dtfi.ShortTimePattern}""")
Console.WriteLine($"Short time string: ""{dateAndTime.ToShortTimeString()}{vbCrLf}")
End Sub
End Module
输出:
Initialize the DateTime object to May 16, 2001 3:02:15 AM. Current culture: "en-US" Long date pattern: "dddd, MMMM d, yyyy" Long date string: "Wednesday, May 16, 2001 Long time pattern: "0" 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