DateTimeFormatInfo.LongDatePattern 속성

정의

긴 날짜 값의 사용자 지정 형식 문자열을 가져오거나 설정합니다.

public:
 property System::String ^ LongDatePattern { System::String ^ get(); void set(System::String ^ value); };
public string LongDatePattern { get; set; }
member this.LongDatePattern : string with get, set
Public Property LongDatePattern As String

속성 값

긴 날짜 값의 사용자 지정 형식 문자열입니다.

예외

속성이 null로 설정되어 있습니다.

속성이 설정되어 있으며 DateTimeFormatInfo 개체가 읽기 전용입니다.

예제

다음 예제에서는 몇 가지 문화권에 LongDatePattern 대 한 속성의 값을 표시 합니다.

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->LongDatePattern );
}

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:

CULTURE    PROPERTY VALUE
en-US     dddd, MMMM dd, yyyy
ja-JP     yyyy'年'M'月'd'日'
fr-FR     dddd d 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.LongDatePattern );
   }
}

/*
This code produces the following output:

 CULTURE    PROPERTY VALUE
  en-US     dddd, MMMM d, yyyy
  ja-JP     yyyy'年'M'月'd'日'
  fr-FR     dddd d 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.LongDatePattern)

   End Sub

End Class

'This code produces the following output:
'
' CULTURE    PROPERTY VALUE
'  en-US     dddd, MMMM d, yyyy
'  ja-JP     yyyy'年'M'月'd'日'
'  fr-FR     dddd d MMMM yyyy
'

설명

속성은 LongDatePattern 및 메서드에 대한 호출 DateTime.ToStringDateTimeOffset.ToString "D" 표준 형식 문자열을 제공하는 복합 형식 문자열에 의해 반환되는 날짜 문자열의 문화권별 형식을 정의합니다. 다음 예제에서는 "D" 표준 형식 문자열, 속성에서 반환 LongDatePattern 된 사용자 지정 형식 문자열 및 날짜의 문화권별 표현 간의 관계를 보여 줍니다.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      DateTime date1 = new DateTime(2011, 11, 12);
      string[] cultureNames = { "en-US", "fr-FR", "ru-RU", "de-DE" };
      Console.WriteLine("{0,-7} {1,-20} {2:D}\n", "Culture", "Long Date Pattern", "Date");
      foreach (var cultureName in cultureNames) {
         CultureInfo culture = CultureInfo.CreateSpecificCulture(cultureName);
         Console.WriteLine("{0,-7} {1,-20} {2}",
                           culture.Name,
                           culture.DateTimeFormat.LongDatePattern,
                           date1.ToString("D", culture));
      }
   }
}
// The example displays the following output:
//    Culture Long Date Pattern    Date
//
//    en-US   dddd, MMMM d, yyyy   Saturday, November 12, 2011
//    fr-FR   dddd d MMMM yyyy     samedi 12 novembre 2011
//    ru-RU   d MMMM yyyy 'г.'     12 ноября 2011 г.
//    de-DE   dddd, d. MMMM yyyy   Samstag, 12. November 2011
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim date1 As Date = #11/12/2011#
      Dim cultureNames() As String = { "en-US", "fr-FR", "ru-RU", "de-DE" }
      Console.WriteLine("{0,-7} {1,-20} {2:D}", "Culture", "Long Date Pattern", "Date")
      Console.WriteLine()
      For Each cultureName In cultureNames
         Dim culture As CultureInfo = CultureInfo.CreateSpecificCulture(cultureName)
         Console.WriteLine("{0,-7} {1,-20} {2}", culture.Name, culture.DateTimeFormat.LongDatePattern, 
                           date1.ToString("D", culture))                 
      Next
   End Sub
End Module
' The example displays the following output:
'    Culture Long Date Pattern    Date
'
'    en-US   dddd, MMMM d, yyyy   Saturday, November 12, 2011
'    fr-FR   dddd d MMMM yyyy     samedi 12 novembre 2011
'    ru-RU   d MMMM yyyy 'г.'     12 ноября 2011 г.
'    de-DE   dddd, d. MMMM yyyy   Samstag, 12. November 2011

"dddd, dd MMMM yyyy"와 같은 사용자 지정 형식 문자열을 생성하기 위해 결합할 수 있는 개별 사용자 지정 형식 지정자는 사용자 지정 날짜 및 시간 형식 문자열을 참조하세요.

날짜 구분 기호 자리 표시자를 사용하는 대신 긴 날짜 패턴의 날짜 구분 기호를 정확한 문자열로 설정해야 합니다. 예를 들어 MM-DD-yyyy 패턴을 가져오려면 긴 날짜 패턴을 "MM-DD-yyyy"로 설정합니다.

문화권에서 사용하는 달력이 변경되면 이 속성의 값이 변경 될 수 있습니다. 예를 들어 다음 예제에서는 문화권에서 사용되는 개체가 변경되면 아랍어(시리아) 문화권을 나타내는 개체의 Calendar 속성 CultureInfo 이 어떻게 변경되는지 LongDatePattern 보여 줍니다.

using System;
using System.Globalization;
using System.IO;

public class Example
{
   public static void Main()
   {
      DateTime date1 = new DateTime(2011, 8, 7);
      CultureInfo ci = CultureInfo.CreateSpecificCulture("ar-SY");
      StreamWriter sw = new StreamWriter(@".\arSYCalendars.txt");

      sw.WriteLine("{0,-32} {1,-21} {2}\n",
                   "Calendar", "Long Date Pattern", "Example Date");
      foreach (var cal in ci.OptionalCalendars) {
         ci.DateTimeFormat.Calendar = cal;
         sw.WriteLine("{0,-32} {1,-21} {2}", GetCalendarName(cal),
                                             ci.DateTimeFormat.LongDatePattern,
                                             date1.ToString("D", ci));
      }
      sw.Close();
   }

   private static string GetCalendarName(Calendar cal)
   {
      string calName;
      calName = cal.GetType().Name.Substring(0, cal.GetType().Name.IndexOf("Cal"));
      if (calName.Equals("Gregorian")) {
         GregorianCalendar grCal = cal as GregorianCalendar;
         calName += String.Format("-{0}", grCal.CalendarType);
      }
      return calName;
   }
}
// The example generates the following output:
//    Calendar                         Long Date Pattern     Example Date
//
//    Gregorian-Localized              dd MMMM, yyyy         07 آب, 2011
//    UmAlQura                         dd/MMMM/yyyy          07/رمضان/1432
//    Hijri                            dd MMMM, yyyy         08 رمضان, 1432
//    Gregorian-USEnglish              dddd, MMMM dd, yyyy   Sunday, August 07, 2011
//    Gregorian-MiddleEastFrench       dddd, MMMM dd, yyyy   dimanche, août 07, 2011
//    Gregorian-TransliteratedEnglish  dddd, MMMM dd, yyyy   الأحد, أغسطس 07, 2011
//    Gregorian-TransliteratedFrench   dddd, MMMM dd, yyyy   الأحد, أوت 07, 2011
Imports System.Globalization
Imports System.IO

Module Example
   Public Sub Main()
      Dim date1 As Date = #8/7/2011#
      Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("ar-SY")
      Dim sw As New StreamWriter(".\arSYCalendars.txt") 

      sw.WriteLine("{0,-32} {1,-21} {2}", 
                   "Calendar", "Long Date Pattern", "Example Date")
      sw.WriteLine()
      For Each cal As Calendar In ci.OptionalCalendars
         ci.DateTimeFormat.Calendar = cal
         sw.WriteLine("{0,-32} {1,-21} {2}", GetCalendarName(cal), 
                                             ci.DateTimeFormat.LongDatePattern,
                                             date1.ToString("D", ci))
      Next     
      sw.Close()
   End Sub
   
   Private Function GetCalendarName(cal As Calendar) As String
      Dim calName As String
      calName = cal.GetType().Name.Substring(0, cal.GetType().Name.IndexOf("Cal"))
      If calName.Equals("Gregorian") Then
         Dim grCal As GregorianCalendar = DirectCast(cal, GregorianCalendar)
         calName += String.Format("-{0}", grCal.CalendarType)    
      End If
      Return calName
   End Function
End Module
' The example generates the following output:
'    Calendar                         Long Date Pattern     Example Date
'    
'    Gregorian-Localized              dd MMMM, yyyy         07 آب, 2011
'    UmAlQura                         dd/MMMM/yyyy          07/رمضان/1432
'    Hijri                            dd MMMM, yyyy         08 رمضان, 1432
'    Gregorian-USEnglish              dddd, MMMM dd, yyyy   Sunday, August 07, 2011
'    Gregorian-MiddleEastFrench       dddd, MMMM dd, yyyy   dimanche, août 07, 2011
'    Gregorian-TransliteratedEnglish  dddd, MMMM dd, yyyy   الأحد, أغسطس 07, 2011
'    Gregorian-TransliteratedFrench   dddd, MMMM dd, yyyy   الأحد, أوت 07, 2011

적용 대상

추가 정보