Window10 cause the system time with the time format data Chinese

 

Convert.ToDateTime (b) .ToString (); -> 1968/3/11 12:00:00 Monday morning

 

Global time using a piece of code using the format set in the program:

 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");
            }

  Before executing this code, or the global system configuration prior to use the code format of the time, will result in Convert.ToDateTime (b) .ToString () -> '2019-09-18'

 

Guess you like

Origin www.cnblogs.com/liuniublogs/p/11120805.html