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)

Source:
Calendar.cs
Source:
Calendar.cs
Source:
Calendar.cs
Source:
Calendar.cs
Source:
Calendar.cs

返回一个 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 小于零或大于 23。

-或-

minute 小于零或大于 59。

-或-

second 小于零或大于 59。

-或-

millisecond 小于零或大于 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)

Source:
Calendar.cs
Source:
Calendar.cs
Source:
Calendar.cs
Source:
Calendar.cs
Source:
Calendar.cs

在派生类中重写时,返回一个 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 小于零或大于 23。

-或-

minute 小于零或大于 59。

-或-

second 小于零或大于 59。

-或-

millisecond 小于零或大于 999。

-或-

era 超出日历支持的范围。

注解

此方法 ToDateTime 很有用,因为它可以将当前日历中的任何日期转换为公历日期。 例如,可以随后使用公历日期来比较不同日历中的日期,或在特定的日历中创建等效日期。

实施者说明

派生类在作为CurrentEra参数传递时必须支持era它。 支持 CurrentEra 的方法之一是将其替换为属性数组的第一个元素 Eras 中存储的值,即日历当前纪元的值。

另请参阅

适用于