相关疑难解决方法(0)

当TimeZoneInfo.ConvertTimeToUtc为某些DateTime值时调用异常

当我为dt的这个特定值运行代码时,当我调用ConvertTimeToUtc方法时会抛出异常.我的本地机器timeZoneId是"GMT标准时间"

var tzi = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
var dt = new DateTime(1995, 4, 2, 2, 55, 0);
var t = TimeZoneInfo.ConvertTimeToUtc(dt, tzi);
Run Code Online (Sandbox Code Playgroud)

例外是:

System.ArgumentException was unhandled
Message="The supplied DateTime represents an invalid time.  For example, when the clock is adjusted forward, any time in the period that is skipped is invalid.\r\nParameter 
Run Code Online (Sandbox Code Playgroud)

c# timezone exception

23
推荐指数
2
解决办法
7893
查看次数

标签 统计

c# ×1

exception ×1

timezone ×1