Create DateTimeOffset from year, month, day, hour, minute, second, millisecond, and offset of a calendar in CSharp
Description
The following code shows how to create DateTimeOffset from year, month, day, hour, minute, second, millisecond, and offset of a calendar.
Example
using System;/*from ww w . j a v a 2s .co m*/
using System.Globalization;
public class MainClass{
public static void Main(String[] argv){
int year = 5344;
Calendar cal = new HebrewCalendar();
DateTimeOffset dateInCal;
CultureInfo fmt = new CultureInfo("he-IL");
fmt.DateTimeFormat.Calendar = cal;
dateInCal = new DateTimeOffset(year, 7, 12,
15, 30, 0, 0,
cal,
new TimeSpan(2, 0, 0));
Console.WriteLine("Date in Hebrew Calendar: {0:g}",
dateInCal.ToString(fmt));
Console.WriteLine("Date in Gregorian Calendar: {0:g}", dateInCal);
}
}
The code above generates the following result.