DateTimeFormatInfo.YearMonthPattern 속성

정의

연도 및 월 값에 대한 사용자 지정 서식 문자열을 가져오거나 설정합니다.

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 및 메서드에 대한 호출 DateTime.ToString 과 "y" 및 DateTimeOffset.ToString "Y" 표준 형식 문자열을 제공하는 복합 형식 문자열에 의해 반환되는 날짜 문자열의 문화권별 형식을 정의합니다.

속성 값이 변경되면 이 속성이 Calendar 영향을 받습니다.

날짜 구분 기호 자리 표시자를 사용하는 대신 연도 월 패턴의 날짜 구분 기호를 정확한 문자열로 설정하는 것이 좋습니다. 예를 들어 MM-yyyy 패턴을 얻으려면 연도 월 패턴을 "MM-yyyy"로 설정합니다.

적용 대상

추가 정보