DateTimeFormatInfo.YearMonthPattern プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
年と月の値のカスタム書式指定文字列を取得または設定します。
public:
property System::String ^ YearMonthPattern { System::String ^ get(); void set(System::String ^ value); };
public string YearMonthPattern { get; set; }
member this.YearMonthPattern : string with get, set
Public Property YearMonthPattern As String
年と月の値のカスタム書式指定文字列。
プロパティが null
に設定されています。
このプロパティが設定されていますが、DateTimeFormatInfo オブジェクトは読み取り専用です。
次の例では、いくつかのカルチャの の YearMonthPattern 値を表示します。
using namespace System;
using namespace System::Globalization;
void PrintPattern( String^ myCulture )
{
CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
Console::WriteLine( " {0} {1}", myCulture, myDTFI->YearMonthPattern );
}
int main()
{
// Displays the values of the pattern properties.
Console::WriteLine( " CULTURE PROPERTY VALUE" );
PrintPattern( "en-US" );
PrintPattern( "ja-JP" );
PrintPattern( "fr-FR" );
}
/*
This code produces the following output. The question marks take the place of native script characters.
CULTURE PROPERTY VALUE
en-US MMMM yyyy
ja-JP yyyy年M月
fr-FR MMMM yyyy
*/
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.YearMonthPattern );
}
}
/*
This code produces the following output. The question marks take the place of native script characters.
CULTURE PROPERTY VALUE
en-US MMMM yyyy
ja-JP yyyy年M月
fr-FR MMMM yyyy
*/
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.YearMonthPattern)
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 yyyy
' ja-JP yyyy年M月
' fr-FR MMMM yyyy
'
プロパティはYearMonthPattern、 メソッドと DateTimeOffset.ToString メソッドの呼び出しDateTime.ToString、および "y" および "Y" 標準書式指定文字列が提供される複合書式指定文字列によって返される日付文字列のカルチャ固有の形式を定義します。
このプロパティは、プロパティの値が変更された場合に影響を Calendar 受けます。
日付区切り記号プレースホルダーを使用する代わりに、年月パターンの日付区切り記号を正確な文字列に設定することをお勧めします。 たとえば、MM-yyyy パターンを取得するには、年月パターンを "MM-yyyy" に設定します。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。