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.
如何将 DB2 ISeries 返回的时间戳转换为 c# 中的 DateTime 数据类型?
2012-07-06 09:52:50.926145
这对我不起作用
myEmployee.LastModified = Convert.ToDateTime(myRecord.GetString(myRecord.GetOrdinal("LASTMODIFIED")));
DateTime.Parse?
DateTime.Parse
DateTime result = DateTime.Parse("2012-07-06 09:52:50.926145");
它确实有效。
你可以这样做DateTime.TryParse()
DateTime.TryParse()
DateTime date; DateTime.TryParse("2012-07-06 09:52:50.926145", out date);
在你的情况下
DateTime date, DateTime.TryParse(myRecord.GetString(myRecord.GetOrdinal("LASTMODIFIED")), out date);