本文整理匯總了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