Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

DateTimeFormatInfo.MonthDayPattern Property

Gets or sets the format pattern for a month and day value, which is associated with the 'm' and 'M' format characters.

[Visual Basic]
Public Property MonthDayPattern As String
[C#]
public string MonthDayPattern {get; set;}
[C++]
public: __property String* get_MonthDayPattern();
public: __property void set_MonthDayPattern(String*);
[JScript]
public function get MonthDayPattern() : String;
public function set MonthDayPattern(String);

Property Value

The format pattern for a month and day value, which is associated with the 'm' and 'M' format characters.

Exceptions

Exception Type Condition
ArgumentNullException The property is being set to a null reference (Nothing in Visual Basic).
InvalidOperationException The property is being set and the DateTimeFormatInfo is read-only.

Remarks

See DateTimeFormatInfo for patterns that can be combined to construct custom patterns; for example, "MMMM dd".

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

Example

[Visual Basic, C#, C++] The following code example displays the value of MonthDayPattern for a few cultures.

[Visual Basic] 
Imports System
Imports System.Globalization

Public Class SamplesDTFI

   Public Shared Sub Main()

      ' Displays the values of the pattern properties.
      Console.WriteLine(" CULTURE    PROPERTY VALUE")
      PrintPattern("en-US")
      PrintPattern("ja-JP")
      PrintPattern("fr-FR")

   End Sub 'Main

   Public Shared Sub PrintPattern(myCulture As [String])

      Dim myDTFI As DateTimeFormatInfo = New CultureInfo(myCulture, False).DateTimeFormat
      Console.WriteLine("  {0}     {1}", myCulture, myDTFI.MonthDayPattern)

   End Sub 'PrintPattern 

End Class 'SamplesDTFI

'This code produces the following output.  The question marks take the place of native script characters.
'
' CULTURE    PROPERTY VALUE
'  en-US     MMMM dd
'  ja-JP     M'?'d'?'
'  fr-FR     d MMMM
'

[C#] 
using System;
using System.Globalization;


public class SamplesDTFI  {

   public static void Main()  {

      // Displays the values of the pattern properties.
      Console.WriteLine( " CULTURE    PROPERTY VALUE" );
      PrintPattern( "en-US" );
      PrintPattern( "ja-JP" );
      PrintPattern( "fr-FR" );

   }

   public static void PrintPattern( String myCulture )  {

      DateTimeFormatInfo myDTFI = new CultureInfo( myCulture, false ).DateTimeFormat;
      Console.WriteLine( "  {0}     {1}", myCulture, myDTFI.MonthDayPattern );

   }

}

/*
This code produces the following output.  The question marks take the place of native script characters.

 CULTURE    PROPERTY VALUE
  en-US     MMMM dd
  ja-JP     M'?'d'?'
  fr-FR     d MMMM

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

void PrintPattern(String * myCulture)
{
   CultureInfo * MyCI = new CultureInfo(myCulture, false);
   DateTimeFormatInfo* myDTFI = MyCI -> DateTimeFormat;
   Console::WriteLine(S" {0} {1}", myCulture, myDTFI -> MonthDayPattern);
}

int main()
{
   // Displays the values of the pattern properties.
   Console::WriteLine(S" CULTURE    PROPERTY VALUE");
   PrintPattern(S"en-US");
   PrintPattern(S"ja-JP");
   PrintPattern(S"fr-FR");
}

/*
This code produces the following output.  The question marks take the place of native script characters.

CULTURE    PROPERTY VALUE
en-US     MMMM dd
ja-JP     M'?'d'?'
fr-FR     d MMMM

*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

DateTimeFormatInfo Class | DateTimeFormatInfo Members | System.Globalization Namespace

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