Mega Code Archive

 
Categories / C# / Date Time
 

DateTimeFormatInfo CurrentInfo TimeSeparator

using System; using System.Globalization; using System.Text.RegularExpressions; using System.Threading; public class Example {    public static void Main()    {       Console.WriteLine("Using the Persian Calendar:");       PersianCalendar persian = new PersianCalendar();       DateTime date1 = new DateTime(2010, 5, 22, 11, 31, 11, 500, persian);       Console.WriteLine(date1.ToString("M/dd/yyyy h:mm:ss.fff tt"));       Console.WriteLine("{0}/{1}/{2} {3}{7}{4:D2}{7}{5:D2}.{6:G3}\n",                                         persian.GetMonth(date1),                                         persian.GetDayOfMonth(date1),                                         persian.GetYear(date1),                                         persian.GetHour(date1),                                         persian.GetMinute(date1),                                         persian.GetSecond(date1),                                         persian.GetMilliseconds(date1),                                         DateTimeFormatInfo.CurrentInfo.TimeSeparator);    } } //   Using the Persian Calendar: //   8/13/2631 11:31:11.500 AM //   5/22/2010 11:31:11.500