DateTimeFormatInfo.LongTimePattern 屬性

定義

取得或設定完整時間值的自訂格式字串。Gets or sets the custom format string for a long time value.

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

屬性值

完整時間值的格式模式。The format pattern for a long time value.

例外狀況

正在將屬性設定為 nullThe property is being set to null.

正在設定屬性,而且 DateTimeFormatInfo 物件為唯讀。The property is being set and the DateTimeFormatInfo object is read-only.

範例

下列範例會顯示一些文化特性LongTimePattern的值。The following example displays the value of LongTimePattern for a few cultures.

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

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     h:mm:ss tt
ja-JP     H:mm:ss
fr-FR     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.LongTimePattern );

   }

}

/*
This code produces the following output.

 CULTURE    PROPERTY VALUE
  en-US     h:mm:ss tt
  ja-JP     H:mm:ss
  fr-FR     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.LongTimePattern)

   End Sub

End Class

'This code produces the following output.
'
' CULTURE    PROPERTY VALUE
'  en-US     h:mm:ss tt
'  ja-JP     H:mm:ss
'  fr-FR     HH:mm:ss
'

備註

屬性會定義日期字串的特定文化特性格式,其由呼叫DateTime.ToStringDateTimeOffset.ToString方法,以及提供 "T" 標準格式字串的複合格式字串所傳回。 LongTimePatternThe LongTimePattern property defines the culture-specific format of date strings that are returned by calls to the DateTime.ToString and DateTimeOffset.ToString methods and by composite format strings that are supplied the "T" standard format string.

我們建議您將完整時間模式中的時間分隔符號設定為精確的字串,而不是使用時間分隔符號預留位置。We recommend that you set the time separator in the long time pattern to an exact string instead of using the time separator placeholder. 例如,若要取得模式 h-mm-ss,請將完整的日期模式設定為 "h-mm-ss"。For example, to obtain the pattern h-mm-ss, set the long date pattern to "h-mm-ss".

適用於

另請參閱