DateTimeFormatInfo.MonthDayPattern プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
月と日の値のカスタム書式指定文字列を取得または設定します。
public:
property System::String ^ MonthDayPattern { System::String ^ get(); void set(System::String ^ value); };
public string MonthDayPattern { get; set; }
member this.MonthDayPattern : string with get, set
Public Property MonthDayPattern As String
プロパティ値
月と日の値のカスタム書式指定文字列。
例外
プロパティは nullに設定されています。
プロパティが設定されており、 DateTimeFormatInfo オブジェクトは読み取り専用です。
例
次の例では、いくつかのカルチャの MonthDayPattern の値を表示します。
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. Note that the exact output format depends on the OS, the OS version, and the native globalization library used by the OS.
CULTURE PROPERTY VALUE
en-US MMMM d
ja-JP M月d日
fr-FR d MMMM
*/
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
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
End Class
'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
'
注釈
MonthDayPattern プロパティは、DateTime.ToStringメソッドとDateTimeOffset.ToStringメソッドの呼び出しによって返される日付文字列のカルチャ固有の形式と、"m" および "M" 標準書式指定文字列が提供される複合書式指定文字列によって定義されます。
このプロパティは、 Calendar プロパティの値が変更された場合に影響を受けます。
日付区切り記号のプレースホルダーを使用する代わりに、月と日のパターンの日付区切り記号を正確な文字列に設定することをお勧めします。 たとえば、MM-DD パターンを取得するには、月と日のパターンを "MM-DD" に設定します。