using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Security.Cryptography;
public class MainClass
{
public static void Main()
{
DateTime dt1 = new DateTime(2004, 10, 9, 22, 47, 35, 259);
DateTimeFormatInfo di = new DateTimeFormatInfo();
for (char c = 'a'; c <= 'z'; c++)
{
try
{
foreach (string s in di.GetAllDateTimePatterns(c))
{
Console.WriteLine("'{0}': {1} - {2}/{3}", c, s,
dt1.ToString(c.ToString()), dt1.ToString(s));
}
char cUpper = Char.ToUpper(c);
foreach (string s in di.GetAllDateTimePatterns(cUpper))
{
Console.WriteLine("'{0}': {1} - {2}", cUpper, s,
dt1.ToString(cUpper.ToString()), dt1.ToString(s));
}
}
catch (ArgumentException)
{
// Ignore--specifier not found.
}
}
}
}
Output 'd': MM/dd/yyyy - 09/10/2004/10/09/2004
'D': dddd, dd MMMM yyyy - October 9, 2004
'f': dddd, dd MMMM yyyy HH:mm - October 9, 2004 10:47 PM/Saturday, 09 October 2004 22:47
'f': dddd, dd MMMM yyyy hh:mm tt - October 9, 2004 10:47 PM/Saturday, 09 October 2004 10:47 PM
'f': dddd, dd MMMM yyyy H:mm - October 9, 2004 10:47 PM/Saturday, 09 October 2004 22:47
'f': dddd, dd MMMM yyyy h:mm tt - October 9, 2004 10:47 PM/Saturday, 09 October 2004 10:47 PM
'F': dddd, dd MMMM yyyy HH:mm:ss - October 9, 2004 10:47:35 PM
'g': MM/dd/yyyy HH:mm - 09/10/2004 10:47 PM/10/09/2004 22:47
'g': MM/dd/yyyy hh:mm tt - 09/10/2004 10:47 PM/10/09/2004 10:47 PM
'g': MM/dd/yyyy H:mm - 09/10/2004 10:47 PM/10/09/2004 22:47
'g': MM/dd/yyyy h:mm tt - 09/10/2004 10:47 PM/10/09/2004 10:47 PM
'G': MM/dd/yyyy HH:mm:ss - 09/10/2004 10:47:35 PM
'm': MMMM dd - October 09/October 09
'M': MMMM dd - October 09
'o': yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK - 2004-10-09T22:47:35.2590000/2004-10-09T22:47:35.259000
0
'O': yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK - 2004-10-09T22:47:35.2590000
'r': ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - Sat, 09 Oct 2004 22:47:35 GMT/Sat, 09 Oct 2004 22:47:35 G
MT
'R': ddd, dd MMM yyyy HH':'mm':'ss 'GMT' - Sat, 09 Oct 2004 22:47:35 GMT
's': yyyy'-'MM'-'dd'T'HH':'mm':'ss - 2004-10-09T22:47:35/2004-10-09T22:47:35
't': HH:mm - 10:47 PM/22:47
't': hh:mm tt - 10:47 PM/10:47 PM
't': H:mm - 10:47 PM/22:47
't': h:mm tt - 10:47 PM/10:47 PM
'T': HH:mm:ss - 10:47:35 PM
'u': yyyy'-'MM'-'dd HH':'mm':'ss'Z' - 2004-10-09 22:47:35Z/2004-10-09 22:47:35Z
'U': dddd, dd MMMM yyyy HH:mm:ss - October 10, 2004 5:47:35 AM
'y': yyyy MMMM - October, 2004/2004 October
'Y': yyyy MMMM - October, 2004
|