Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

DateTimeFormatInfo.ShortDatePattern Property

Gets or sets the custom format string for a short date value.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)
Public Property ShortDatePattern As String

Property Value

Type: System.String
The custom format string for a short date value.

The property is being set to Nothing.


The property is being set and the DateTimeFormatInfo object is read-only.

The ShortDatePattern property defines the culture-specific format of date strings that are returned by calls to the DateTime.ToString and DateTimeOffset.ToString methods and by composite format strings that are supplied the "d" standard format string.

This property is affected if the value of the Calendar property changes.

The following example displays the value of the ShortDatePattern property and the value of a date formatted using the ShortDatePattern property for a few cultures.

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")

      For Each culture As String In cultures
         Dim dtfi As DateTimeFormatInfo = CultureInfo.CreateSpecificCulture(culture).DateTimeFormat
         Console.WriteLine(" {0,7} {1,19} {2,10}", culture, 
                           date1.ToString("d", dtfi))
   End Sub  
End Class 
' The example displays the following output: 
'        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

The following example modifies the ShortDatePattern property of a DateTimeFormatInfo object that represents the formatting conventions of the English (United States) culture. It also displays a date value twice, first to reflect the original ShortDatePattern property and then to reflect the new property value.

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 
' The example displays the following output: 
'    Original Short Date Pattern: 
'       M/d/yyyy: 5/1/2011 
'    Revised Short Date Pattern: 
'       YYYY/MM/dd: 2011-05-01

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.