如何在日历之间转换?以下是我所拥有的:

UmAlQuraCalendar hijri = new UmAlQuraCalendar();
GregorianCalendar cal = new GregorianCalendar();

DateTime hijriDate = new DateTime(1434, 11, 23, hijri);
DateTime gregorianDate = ...; //

我需要一个对应于gregorianDatehijriDate

最佳答案

似乎DateTime中保存的日期总是在当前日历中。所以如果当前日历是公历,那么它已经是公历了。

var hijriDate = new DateTime(1434, 11, 23, hijri);
//Console writeline will show 2013-09-29 00:00:00

如果当前日历hijriDate您应该能够使用以下方法提取公历日期:
var hijri = new UmAlQuraCalendar();
var cal = new GregorianCalendar();

var hijriDate = new DateTime(1434, 11, 23, hijri);
var y = cal.GetYear(hijriDate),
var m = cal.GetMonth(hijriDate),
var d = cal.GetDayOfMonth(hijriDate)

09-26 14:39