解决C#时间格式问题,不在受系统时间格式影响

版权声明:本文为博主原创文章,未经博主允许不得转载。 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");
            }

猜你喜欢

转载自blog.csdn.net/rrrgy236116/article/details/78520669