Create DateTime from year, month, day, hour, minute, and second for the specified calendar in CSharp
Description
The following code shows how to create DateTime from year, month, day, hour, minute, and second for the specified calendar.
Example
//from w w w . j av a 2 s . co m
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(1389, 5, 27, 16, 32, 0, persian);
Console.WriteLine(date1.ToString());
Console.WriteLine("{0}/{1}/{2} {3}{6}{4:D2}{6}{5:D2}\n",
persian.GetMonth(date1),
persian.GetDayOfMonth(date1),
persian.GetYear(date1),
persian.GetHour(date1),
persian.GetMinute(date1),
persian.GetSecond(date1),
DateTimeFormatInfo.CurrentInfo.TimeSeparator);
}
}
The code above generates the following result.