【发布时间】:2012-07-25 07:50:49
【问题描述】:
我有一个奇怪的问题:
string format = @"ddd MMM dd hh:mm:ss \G\M\Tzzz yyyy";
__timestamp = "Fri Apr 09 17:02:00 GMT-0500 2010";
DateTime.ParseExact(__timestamp, format, new CultureInfo("en"));
返回FormatException = “字符串未被识别为有效的日期时间。”
但该代码没有异常:
string format = @"ddd MMM dd hh:mm:ss \G\M\Tzzz yyyy";
__timestamp = "Sat Apr 10 01:27:00 GMT-0500 2010";
DateTime.ParseExact(__timestamp, format, new CultureInfo("en"));
从该格式的 30k 日期解析中,大约 50% 的日期解析失败,但出现该异常...
有人知道为什么吗?
【问题讨论】:
标签: c# .net string exception datetime