ALL the patterns
using System;
using System.Globalization;
public class SamplesDateTimeFormatInfo {
public static void Main() {
DateTimeFormatInfo myDtfi = new DateTimeFormatInfo();
String[] myPatternsArray = myDtfi.GetAllDateTimePatterns();
PrintIndexAndValues( myPatternsArray );
myPatternsArray = myDtfi.GetAllDateTimePatterns('d');
Console.WriteLine( "The patterns for 'd':" );
PrintIndexAndValues( myPatternsArray );
myPatternsArray = myDtfi.GetAllDateTimePatterns('D');
Console.WriteLine( "The patterns for 'D':" );
PrintIndexAndValues( myPatternsArray );
myPatternsArray = myDtfi.GetAllDateTimePatterns('f');
Console.WriteLine( "The patterns for 'f':" );
PrintIndexAndValues( myPatternsArray );
myPatternsArray = myDtfi.GetAllDateTimePatterns('F');
Console.WriteLine( "The patterns for 'F':" );
PrintIndexAndValues( myPatternsArray );
myPatternsArray = myDtfi.GetAllDateTimePatterns('r');
Console.WriteLine( "The patterns for 'r':" );
PrintIndexAndValues( myPatternsArray );
myPatternsArray = myDtfi.GetAllDateTimePatterns('R');
Console.WriteLine( "The patterns for 'R':" );
PrintIndexAndValues( myPatternsArray );
}
public static void PrintIndexAndValues( String[] myArray ) {
int i = 0;
foreach ( String s in myArray )
Console.WriteLine( "\t[{0}]:\t{1}", i++, s );
}
}
/*
[0]: MM/dd/yyyy
[1]: yyyy-MM-dd
[2]: dddd, dd MMMM yyyy
[3]: dddd, dd MMMM yyyy HH:mm
[4]: dddd, dd MMMM yyyy hh:mm tt
[5]: dddd, dd MMMM yyyy H:mm
[6]: dddd, dd MMMM yyyy h:mm tt
[7]: dddd, dd MMMM yyyy HH:mm:ss
[8]: MM/dd/yyyy HH:mm
[9]: MM/dd/yyyy hh:mm tt
[10]: MM/dd/yyyy H:mm
[11]: MM/dd/yyyy h:mm tt
[12]: yyyy-MM-dd HH:mm
[13]: yyyy-MM-dd hh:mm tt
[14]: yyyy-MM-dd H:mm
[15]: yyyy-MM-dd h:mm tt
[16]: MM/dd/yyyy HH:mm:ss
[17]: yyyy-MM-dd HH:mm:ss
[18]: MMMM dd
[19]: MMMM dd
[20]: yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK
[21]: yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK
[22]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
[23]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
[24]: yyyy'-'MM'-'dd'T'HH':'mm':'ss
[25]: HH:mm
[26]: hh:mm tt
[27]: H:mm
[28]: h:mm tt
[29]: HH:mm:ss
[30]: yyyy'-'MM'-'dd HH':'mm':'ss'Z'
[31]: dddd, dd MMMM yyyy HH:mm:ss
[32]: yyyy MMMM
[33]: yyyy MMMM
The patterns for 'd':
[0]: MM/dd/yyyy
[1]: yyyy-MM-dd
The patterns for 'D':
[0]: dddd, dd MMMM yyyy
The patterns for 'f':
[0]: dddd, dd MMMM yyyy HH:mm
[1]: dddd, dd MMMM yyyy hh:mm tt
[2]: dddd, dd MMMM yyyy H:mm
[3]: dddd, dd MMMM yyyy h:mm tt
The patterns for 'F':
[0]: dddd, dd MMMM yyyy HH:mm:ss
The patterns for 'r':
[0]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
The patterns for 'R':
[0]: ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
*/
Related examples in the same category