• <small id='SZ5ed'></small><noframes id='SZ5ed'>

      <legend id='SZ5ed'><style id='SZ5ed'><dir id='SZ5ed'><q id='SZ5ed'></q></dir></style></legend>
      <i id='SZ5ed'><tr id='SZ5ed'><dt id='SZ5ed'><q id='SZ5ed'><span id='SZ5ed'><b id='SZ5ed'><form id='SZ5ed'><ins id='SZ5ed'></ins><ul id='SZ5ed'></ul><sub id='SZ5ed'></sub></form><legend id='SZ5ed'></legend><bdo id='SZ5ed'><pre id='SZ5ed'><center id='SZ5ed'></center></pre></bdo></b><th id='SZ5ed'></th></span></q></dt></tr></i><div id='SZ5ed'><tfoot id='SZ5ed'></tfoot><dl id='SZ5ed'><fieldset id='SZ5ed'></fieldset></dl></div>

      1. <tfoot id='SZ5ed'></tfoot>
          <bdo id='SZ5ed'></bdo><ul id='SZ5ed'></ul>

        回历和公历 DateTime 构造函数

        时间:2023-08-26

            <tfoot id='J51DC'></tfoot>
              <bdo id='J51DC'></bdo><ul id='J51DC'></ul>
              <i id='J51DC'><tr id='J51DC'><dt id='J51DC'><q id='J51DC'><span id='J51DC'><b id='J51DC'><form id='J51DC'><ins id='J51DC'></ins><ul id='J51DC'></ul><sub id='J51DC'></sub></form><legend id='J51DC'></legend><bdo id='J51DC'><pre id='J51DC'><center id='J51DC'></center></pre></bdo></b><th id='J51DC'></th></span></q></dt></tr></i><div id='J51DC'><tfoot id='J51DC'></tfoot><dl id='J51DC'><fieldset id='J51DC'></fieldset></dl></div>

              <small id='J51DC'></small><noframes id='J51DC'>

              <legend id='J51DC'><style id='J51DC'><dir id='J51DC'><q id='J51DC'></q></dir></style></legend>

                    <tbody id='J51DC'></tbody>
                1. 本文介绍了回历和公历 DateTime 构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  传递给 DateTime 类型构造函数的 Calendar 对象的正确行为是什么?

                  what is the correct behavior for the Calendar objected passed to the constructor of DateTime type?

                  我有如下示例的年、月和日组件:

                  I have the components year, month and day as the below example:

                  day = 1
                  month = 5 
                  year = 1433 (which is the current Hijri year)
                  

                  当使用下面的代码创建一个日期时间对象时,结果是一个有效的格雷格日期

                  when creating a datetime object using the below code the result is a valid Greg Date

                  HijriCalendar hijri = new HijriCalendar();
                  //Get the First Day in the Month
                  DateTime firstDayInMonth = new DateTime(1433, month, 1, hijri);
                  

                  使用下面的代码会生成一个有效的回历日期:

                  while using the below code generates a valid Hijri date:

                  GregorianCalendar greg = new GregorianCalendar();
                  //Get the First Day in the Month
                  DateTime firstDayInMonth = new DateTime(1433, month, 1, greg);
                  

                  这是正确的结果吗?

                  推荐答案

                  你的第一个例子是正确的.DateTime 不会采用 Hijri 格式,它只是您给它的标准化等价物.如何获取 Hirji 日期请参见以下代码:

                  Your first example is correct. The DateTime will not be in the Hijri format, it will just be the standardised equivalent of what you gave it. See the following code for how to get the Hirji date:

                  HijriCalendar hijri = new HijriCalendar();
                  DateTime firstDayInMonth = new DateTime(1433, 10, 11, hijri);
                  Console.WriteLine(hijri.GetEra(firstDayInMonth)); // 1
                  Console.WriteLine(hijri.GetYear(firstDayInMonth)); // 1433
                  Console.WriteLine(hijri.GetMonth(firstDayInMonth)); // 10
                  Console.WriteLine(hijri.GetDayOfMonth(firstDayInMonth)); // 11
                  

                  您的第二个代码块只是将公历日期设置为1/1/1433",因此当您检查它时,您并没有得到 hirji 日期,而只是得到了您在 15 世纪给出的日期.

                  Your second block of code was just setting the gregorian date "1/1/1433" so when you were inspecting it you weren't getting a hirji date, you were just getting the date you gave it in the 15th century.

                  查看 http://msdn.microsoft.com/en-us/library/system.globalization.hijricalendar.aspx 并查看其中的方法应该可以让您更好地了解应该在日历对象上做什么以及在 DateTime 对象上应该发生什么.

                  Looking at http://msdn.microsoft.com/en-us/library/system.globalization.hijricalendar.aspx and seeing the methods there should give you a better idea of what you should be doing on the calendar object and what should happen on the DateTime object.

                  这篇关于回历和公历 DateTime 构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:按住鼠标的 WPF 日历控件 下一篇:日历自定义验证器

                  相关文章

                  最新文章

                2. <legend id='Jac89'><style id='Jac89'><dir id='Jac89'><q id='Jac89'></q></dir></style></legend>

                  <small id='Jac89'></small><noframes id='Jac89'>

                  1. <tfoot id='Jac89'></tfoot>

                      • <bdo id='Jac89'></bdo><ul id='Jac89'></ul>
                      <i id='Jac89'><tr id='Jac89'><dt id='Jac89'><q id='Jac89'><span id='Jac89'><b id='Jac89'><form id='Jac89'><ins id='Jac89'></ins><ul id='Jac89'></ul><sub id='Jac89'></sub></form><legend id='Jac89'></legend><bdo id='Jac89'><pre id='Jac89'><center id='Jac89'></center></pre></bdo></b><th id='Jac89'></th></span></q></dt></tr></i><div id='Jac89'><tfoot id='Jac89'></tfoot><dl id='Jac89'><fieldset id='Jac89'></fieldset></dl></div>