Calendar.ToDateTime 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当在派生类中重写时,返回设置为指定日期和时间的 DateTime。
重载
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) |
返回设置为当前纪元中指定日期和时间的 DateTime。 |
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32) |
当在派生类中重写时,将返回设置为指定纪元中指定日期和时间的 DateTime。 |
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
返回设置为当前纪元中指定日期和时间的 DateTime。
public:
virtual DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond);
public virtual DateTime ToDateTime (int year, int month, int day, int hour, int minute, int second, int millisecond);
abstract member ToDateTime : int * int * int * int * int * int * int -> DateTime
override this.ToDateTime : int * int * int * int * int * int * int -> DateTime
Public Overridable Function ToDateTime (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, millisecond As Integer) As DateTime
参数
- year
- Int32
一个整数,用于表示年份。
- month
- Int32
一个正整数,用于表示月份。
- day
- Int32
一个正整数,用于表示天。
- hour
- Int32
0 到 23 之间的一个整数,用于表示小时。
- minute
- Int32
0 到 59 之间的一个整数,用于表示分钟。
- second
- Int32
0 到 59 之间的一个整数,用于表示秒。
- millisecond
- Int32
0 到 999 之间的一个整数,用于表示毫秒。
返回
设置为当前纪元中指定日期和时间的 DateTime。
例外
year
超出了日历支持的范围。
或 -
month
超出了日历支持的范围。或 -
day
超出了日历支持的范围。或 -
hour
小于 0 或大于 23。或 -
minute
小于 0 或大于 59。或 -
second
小于 0 或大于 59。或 -
millisecond
小于 0 或大于 999。
注解
此方法根据特定日历的当前时代返回日期和时间。 JapaneseCalendar JapaneseLunisolarCalendar对于支持基于皇帝统治的多个时代,调用此方法可以产生一个意外的日期,当时代发生变化。 使用这些日历之一实例化日期时,建议调用JapaneseCalendar.ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)或日语LunisolarCalendar.ToDateTime (Int32,Int32,Int32,Int32,Int32,Int32,Int32,Int32,Int32) 方法并显式指定纪元。
另请参阅
适用于
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
当在派生类中重写时,将返回设置为指定纪元中指定日期和时间的 DateTime。
public:
abstract DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era);
public abstract DateTime ToDateTime (int year, int month, int day, int hour, int minute, int second, int millisecond, int era);
abstract member ToDateTime : int * int * int * int * int * int * int * int -> DateTime
Public MustOverride Function ToDateTime (year As Integer, month As Integer, day As Integer, hour As Integer, minute As Integer, second As Integer, millisecond As Integer, era As Integer) As DateTime
参数
- year
- Int32
一个整数,用于表示年份。
- month
- Int32
一个正整数,用于表示月份。
- day
- Int32
一个正整数,用于表示天。
- hour
- Int32
0 到 23 之间的一个整数,用于表示小时。
- minute
- Int32
0 到 59 之间的一个整数,用于表示分钟。
- second
- Int32
0 到 59 之间的一个整数,用于表示秒。
- millisecond
- Int32
0 到 999 之间的一个整数,用于表示毫秒。
- era
- Int32
一个整数,用于表示纪元。
返回
设置为当前纪元中指定日期和时间的 DateTime。
例外
year
超出了日历支持的范围。
或 -
month
超出了日历支持的范围。或 -
day
超出了日历支持的范围。或 -
hour
小于 0 或大于 23。或 -
minute
小于 0 或大于 59。或 -
second
小于 0 或大于 59。或 -
millisecond
小于 0 或大于 999。或 -
era
超出了日历支持的范围。
注解
此方法 ToDateTime 非常有用,因为它可以将当前日历中的任何日期转换为公历日期。 例如,随后可以使用公历日期来比较不同日历中的日期,或在特定日历中创建等效日期。
实施者说明
当派生类作为era
参数传递时,派生类必须支持CurrentEra它。 支持的 CurrentEra 一种方法是将其替换为属性数组的第一个元素 Eras 中存储的值,即日历当前时代的值。