Calendar.ToDateTime 方法

定义

当在派生类中重写时,返回设置为指定日期和时间的 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)JapaneseLunisolarCalendar.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 中存储的值,该值是日历的当前纪元的值。

另请参阅

适用于