版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rrrgy236116/article/details/78520669
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");
}