Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我收到此错误:
System.FormatException:字符串未被识别为有效的 DateTime
当我将 Google plus 日期转换为印度时区时。我使用这段代码:
private static DateTime Getdate(string published) { return DateTime.ParseExact(published, "MM/dd/yyyy", CultureInfo.InvariantCulture); }
提前致谢。
DateTime.ParseExact 方法的第二个参数必须与第一个参数的格式匹配。尝试像这样更改您的代码:
private static DateTime Getdate(string published) { return DateTime.ParseExact(published, "yyyy-MM-ddTHH:mm:ss.fffZ", New CultureInfo("hi-IN")); }