以 24 小时格式创建 DateTime 对象
Create DateTime Object in 24 Hour Format
我正在使用此构造函数创建 DateTime 对象
public DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond);
但问题是我的小时值是 24 小时格式。
所以当我这样做时
DateTime dTime = new DateTime(2015, 2, 16, 30, 25, 34);
我在 mscorlib.dll
中收到类型为 'System.ArgumentOutOfRangeException' 的未处理异常
因为在公历 or any calender as far as I know 中没有 30
作为一天中的小时。
正如 documentation 所指出的那样;
hour Type: System.Int32
The hours (0 through 23).
这与 24 hour format 无关。当您尝试获取 DateTime
.
的字符串表示时,格式 only 适用
我正在使用此构造函数创建 DateTime 对象
public DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond);
但问题是我的小时值是 24 小时格式。 所以当我这样做时
DateTime dTime = new DateTime(2015, 2, 16, 30, 25, 34);
我在 mscorlib.dll
中收到类型为 'System.ArgumentOutOfRangeException' 的未处理异常因为在公历 or any calender as far as I know 中没有 30
作为一天中的小时。
正如 documentation 所指出的那样;
hour Type: System.Int32
The hours (0 through 23).
这与 24 hour format 无关。当您尝试获取 DateTime
.