DateTimeFormatInfo.UniversalSortableDateTimePattern 屬性

定義

取得自訂格式字串,以取得由 ISO 8601 所定義的國際標準、可排序日期和時間字串。Gets the custom format string for a universal, sortable date and time string, as defined by ISO 8601.

public:
 property System::String ^ UniversalSortableDateTimePattern { System::String ^ get(); };
public string UniversalSortableDateTimePattern { get; }
member this.UniversalSortableDateTimePattern : string
Public ReadOnly Property UniversalSortableDateTimePattern As String

屬性值

國際標準、可排序日期和時間字串的自訂格式字串。The custom format string for a universal, sortable date and time string.

範例

下列範例會顯示一些文化特性UniversalSortableDateTimePattern的值。The following example displays the value of UniversalSortableDateTimePattern 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->UniversalSortableDateTimePattern );
}

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     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
ja-JP     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
fr-FR     yyyy'-'MM'-'dd HH':'mm':'ss'Z'

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

   }

}

/*
This code produces the following output.

 CULTURE    PROPERTY VALUE
  en-US     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
  ja-JP     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
  fr-FR     yyyy'-'MM'-'dd HH':'mm':'ss'Z'

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

   End Sub

End Class

'This code produces the following output.
'
' CULTURE    PROPERTY VALUE
'  en-US     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
'  ja-JP     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
'  fr-FR     yyyy'-'MM'-'dd HH':'mm':'ss'Z'
'

備註

屬性會定義透過呼叫DateTime.ToStringDateTimeOffset.ToString方法所傳回的日期字串格式,以及提供 "u" 標準格式字串的複合格式字串。 UniversalSortableDateTimePatternThe UniversalSortableDateTimePattern property defines the 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 "u" standard format string. 它可以用來以可排序的順序顯示日期和時間,其結尾會有通用時間指示項 "Z"。It can be used to display dates and times in a sortable order with the universal time designator "Z" at the end. 此格式是可排序的,因為它會針對 year、month、day、hour、minute 和 second 使用前置零。The format is sortable because it uses leading zeros for year, month, day, hour, minute, and second. 不論文化特性或格式提供者為何,自訂格式字串("yyyy'-'mm'-'dd't'hh-YYYY'-'MM'-'DD'T'HH-'dd HH ': ' MM ': ' ss'Z '")都相同。The custom format string ("yyyy'-'MM'-'dd HH':'mm':'ss'Z'") is the same regardless of culture or format provider.

UniversalSortableDateTimePattern屬性所傳回的格式字串會反映已定義的標準,且屬性為唯讀。The format string returned by the UniversalSortableDateTimePattern property reflects a defined standard, and the property is read-only. 因此,無論文化特性為何,它一律是相同的。Therefore, it is always the same, regardless of the culture. 自訂格式字串為 "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"。The custom format string is "yyyy'-'MM'-'dd HH':'mm':'ss'Z'".

適用於

另請參閱