DateTimeFormatInfo.GetAllDateTimePatterns : DateTimeFormatInfo « System.Globalization « C# / C Sharp by API






DateTimeFormatInfo.GetAllDateTimePatterns

    

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.
            }
        }
    }
}

   
    
    
    
  








Related examples in the same category

1.DateTimeFormatInfo.CurrentInfo
2.DateTimeFormatInfo.DateSeparator
3.DateTimeFormatInfo.DateTimeFormat
4.DateTimeFormatInfo.LongDatePattern
5.DateTimeFormatInfo.TimeSeparator