本文整理汇总了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