DateTimeFormatInfo.FullDateTimePattern 属性

定义

为长日期和长时间值获取或设置自定义格式字符串。

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

属性值

String

长日期和时间值的自定义格式字符串。

例外

该属性设置为 null

设置了该属性,但 DateTimeFormatInfo 对象为只读。

示例

下面的示例显示了几个区域性的的值 FullDateTimePattern

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

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     dddd, MMMM dd, yyyy h:mm:ss tt
ja-JP     yyyy'年'M'月'd'日' H:mm:ss
fr-FR     dddd d MMMM yyyy HH:mm:ss

*/
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.FullDateTimePattern );
   }
}

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

 CULTURE    PROPERTY VALUE
  en-US     dddd, MMMM dd, yyyy h:mm:ss tt
  ja-JP     yyyy'年'M'月'd'日' H:mm:ss
  fr-FR     dddd d MMMM yyyy HH:mm:ss

*/
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.FullDateTimePattern)

   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     dddd, MMMM dd, yyyy h:mm:ss tt
'  ja-JP     yyyy'年'M'月'd'日' H:mm:ss
'  fr-FR     dddd d MMMM yyyy HH:mm:ss
'

注解

"F" 标准格式字符串是属性的别名 FullDateTimePattern 。 换言之,分配给此属性的自定义格式字符串为 "F" 标准格式字符串定义结果字符串的格式。 有关详细信息,请参阅 标准日期和时间格式字符串

属性的值 FullDateTimePattern 是通过串联 LongDatePattern 由空格分隔的和属性来动态生成的 LongTimePattern 。 此动态分配在下列情况下发生:

  • 如果在显式设置属性值之前检索到属性值,则为。

  • 当属性的值 LongDatePattern 更改时。

  • 当属性的值 LongTimePattern 更改时。

如果属性的值发生更改,则此属性将受到影响 Calendar

适用于

另请参阅