本文整理匯總了VB.NET中System.Globalization.DateTimeFormatInfo.ShortDatePattern屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateTimeFormatInfo.ShortDatePattern屬性的具體用法?VB.NET DateTimeFormatInfo.ShortDatePattern怎麽用?VB.NET DateTimeFormatInfo.ShortDatePattern使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Globalization.DateTimeFormatInfo
的用法示例。
在下文中一共展示了DateTimeFormatInfo.ShortDatePattern屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: SamplesDTFI
' 導入命名空間
Imports System.Globalization
Public Class SamplesDTFI
Public Shared Sub Main()
Dim cultures() As String = { "en-US", "ja-JP", "fr-FR" }
Dim date1 As Date = #05/01/2011#
Console.WriteLine(" {0,7} {1,19} {2,10}", "CULTURE", "PROPERTY VALUE", "DATE")
Console.WriteLine()
For Each culture As String In cultures
Dim dtfi As DateTimeFormatInfo = CultureInfo.CreateSpecificCulture(culture).DateTimeFormat
Console.WriteLine(" {0,7} {1,19} {2,10}", culture,
dtfi.ShortDatePattern,
date1.ToString("d", dtfi))
Next
End Sub
End Class
輸出:
CULTURE PROPERTY VALUE DATE en-US M/d/yyyy 5/1/2011 ja-JP yyyy/MM/dd 2011/05/01 fr-FR dd/MM/yyyy 01/05/2011
示例2: Example
' 導入命名空間
Imports System.Globalization
Module Example
Public Sub Main()
Dim dtfi As DateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat
Dim date1 As DateTime = #05/01/2011#
Console.WriteLine("Original Short Date Pattern:")
Console.WriteLine(" {0}: {1}", dtfi.ShortDatePattern,
date1.ToString("d", dtfi))
dtfi.DateSeparator = "-"
dtfi.ShortDatePattern = "yyyy/MM/dd"
Console.WriteLine("Revised Short Date Pattern:")
Console.WriteLine(" {0}: {1}", dtfi.ShortDatePattern,
date1.ToString("d", dtfi))
End Sub
End Module
輸出:
Original Short Date Pattern: M/d/yyyy: 5/1/2011 Revised Short Date Pattern: YYYY/MM/dd: 2011-05-01