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)

來源:
Calendar.cs
來源:
Calendar.cs
來源:
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 小於 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) 方法,並明確指定紀元。

另請參閱

適用於

ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

來源:
Calendar.cs
來源:
Calendar.cs
來源:
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 小於 0 或大於 23。

-或-

minute 小於 0 或大於 59。

-或-

second 小於 0 或大於 59。

-或-

millisecond 小於 0 或大於 999。

-或-

era 不在曆法支援的範圍內。

備註

方法 ToDateTime 很有用,因為它可以將目前行事曆中的任何日期轉換成公曆日期。 例如,您可以後續使用公曆日期來比較不同行事曆中的日期,或在特定行事曆中建立相等的日期。

給實施者的注意事項

衍生類別必須支持 CurrentEra 當做 era 參數傳遞時。 其中一個支援 CurrentEra 方式是將它取代為屬性陣列第一個專案 Eras 中儲存的值,也就是行事曆目前紀元的值。

另請參閱

適用於