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”。