UniversalSortableDateTimePattern Property

DateTimeFormatInfo.UniversalSortableDateTimePattern Property

Gets the format pattern for a universal sortable date and time value, which is associated with the 'u' and 'U' format characters.

[Visual Basic]
Public ReadOnly Property UniversalSortableDateTimePattern As String
[C#]
public string UniversalSortableDateTimePattern {get;}
[C++]
public: __property String* get_UniversalSortableDateTimePattern();
[JScript]
public function get UniversalSortableDateTimePattern() : String;

Property Value

The format pattern for a universal sortable date and time value, which is associated with the 'u' and 'U' format characters.

Remarks

UniversalSortableDateTimePattern can be used to display time in a sortable format with the universal time designator "Z" at the end. The format is sortable because it uses leading zeros for year, month, day, hour, minute, and second. The pattern ("yyyy'-'MM'-'dd HH':'mm':'ss'Z'") is the same regardless of culture or format provider.

Example

[Visual Basic, C#, C++] The following code example displays the value of UniversalSortableDateTimePattern for a few cultures.

[Visual Basic] 
Imports System
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 'Main

   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 'PrintPattern 

End Class 'SamplesDTFI

'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'
'

[C#] 
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'

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

void PrintPattern(String * myCulture)
{
   CultureInfo * MyCI = new CultureInfo(myCulture, false);
   DateTimeFormatInfo* myDTFI = MyCI -> DateTimeFormat;
   Console::WriteLine(S" {0} {1}", myCulture, myDTFI -> UniversalSortableDateTimePattern);
}

int main()
{
   // Displays the values of the pattern properties.
   Console::WriteLine(S" CULTURE    PROPERTY VALUE");
   PrintPattern(S"en-US");
   PrintPattern(S"ja-JP");
   PrintPattern(S"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'

*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DateTimeFormatInfo Class | DateTimeFormatInfo Members | System.Globalization Namespace | SortableDateTimePattern

Show:
© 2016 Microsoft