Calendar.ToDateTime 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當在衍生類別中覆寫時,回傳設定為指定日期與時間的 a DateTime 。
多載
| 名稱 | Description |
|---|---|
| ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32) |
回傳設定為當前時代指定日期與時間的 a DateTime 。 |
| ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32) |
當在衍生類別中覆寫時,會回傳設定為指定時代的日期與時間的 a DateTime 。 |
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
回傳設定為當前時代指定日期與時間的 a 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,Int32) 方法,並明確指定一個時代。
另請參閱
適用於
ToDateTime(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
- 來源:
- Calendar.cs
當在衍生類別中覆寫時,會回傳設定為指定時代的日期與時間的 a 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 中的值,也就是當前曆法時代的值。