DateTimeFormatInfo.SortableDateTimePattern 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得可排序日期和時間值的自訂格式字串。
public:
property System::String ^ SortableDateTimePattern { System::String ^ get(); };
public string SortableDateTimePattern { get; }
member this.SortableDateTimePattern : string
Public ReadOnly Property SortableDateTimePattern As String
屬性值
可排序日期和時間值的自訂格式字串。
範例
下列範例會顯示幾個文化特性的值 SortableDateTimePattern 。
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->SortableDateTimePattern );
}
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'T'HH':'mm':'ss
ja-JP yyyy'-'MM'-'dd'T'HH':'mm':'ss
fr-FR yyyy'-'MM'-'dd'T'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.SortableDateTimePattern );
}
}
/*
This code produces the following output.
CULTURE PROPERTY VALUE
en-US yyyy'-'MM'-'dd'T'HH':'mm':'ss
ja-JP yyyy'-'MM'-'dd'T'HH':'mm':'ss
fr-FR yyyy'-'MM'-'dd'T'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.SortableDateTimePattern)
End Sub
End Class
'This code produces the following output.
'
' CULTURE PROPERTY VALUE
' en-US yyyy'-'MM'-'dd'T'HH':'mm':'ss
' ja-JP yyyy'-'MM'-'dd'T'HH':'mm':'ss
' fr-FR yyyy'-'MM'-'dd'T'HH':'mm':'ss
'
備註
屬性 SortableDateTimePattern 會定義呼叫 DateTime.ToString 和 DateTimeOffset.ToString 方法以及提供 「s」 標準格式字串之複合格式字串所傳回之日期字串的文化特性特定格式。
屬性所 SortableDateTimePattern 傳回的格式字串會反映定義的標準 (ISO 8601) ,而且屬性是只讀的。 因此,不論文化特性為何,它一律相同。 自訂格式字串為 "yyyy'-'MM'-'dd'T'HH':'mm':'ss"。