【发布时间】:2011-12-22 17:54:05
【问题描述】:
传递给 DateTime 类型构造函数的 Calendar 对象的正确行为是什么?
我有如下示例的年、月和日组件:
day = 1
month = 5
year = 1433 (which is the current Hijri year)
当使用下面的代码创建一个日期时间对象时,结果是一个有效的格雷格日期
HijriCalendar hijri = new HijriCalendar();
//Get the First Day in the Month
DateTime firstDayInMonth = new DateTime(1433, month, 1, hijri);
使用下面的代码会生成一个有效的回历日期:
GregorianCalendar greg = new GregorianCalendar();
//Get the First Day in the Month
DateTime firstDayInMonth = new DateTime(1433, month, 1, greg);
这是正确的结果吗?
【问题讨论】:
-
看到两个日历上都有一个特定的日期,到底是什么问题?
-
您是否正在尝试将回历转换为公历,这样如果您输入回历 1433 年就会得到公历 2011 年?
-
@ChrisBD :是的,我想通过传递被认为是回历的组件来获取公历日期,反之亦然