陆陆续续写了几个程序,批量导入之后总会遇到这么几台报错的,然后一看就发现是车间设备系统时间格式不同。
所以,本着为现场排忧解难的态度(其实就是懒),格式化时间好了。
代码附上:
if (DateTimeFormatInfo.CurrentInfo != null) { var type = DateTimeFormatInfo.CurrentInfo.GetType(); var field = type.GetField("generalLongTimePattern", BindingFlags.NonPublic | BindingFlags.Instance); if (field != null) field.SetValue(DateTimeFormatInfo.CurrentInfo, "yyyy-MM-dd HH:mm:ss"); }