DateTimeFormatInfo.MonthDayPattern has changed in Windows Server 2012 - How can I install it back?

In Australia, a customer entered "1/5" as a shortcut on the first day of May. We just upgraded from Windows Server 2008 to Windows Server 2012.

Using the following code in LinqPad:

 Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-au", false); System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthDayPattern.Dump(); DateTime.Parse("1/5").Dump(); 

In Windows Server 2008:

dd MMMM

05/01/2016 12:00:00 AM

In Windows Server 2012 R2:

MMMM d

01/05/2016 12:00:00 AM

Questions:

  • Why has the MonthDayPattern changed? Australians always have the first day, then the month.
  • Where can this be installed in the Windows Server user interface? The user interface provides only long and short formats, not the month and day format.
  • How can I fix the problem in my application with the least amount of changes, given that the system can have DateTime.Parse (for example, model binding, validation, etc.).
+6
source share
1 answer

I can replicate the problem on Windows Server 2012. If you added ...

 System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern.Dump(); 

you will see that he is returning ...

d / MM / YYYY

This is just a MonthDayPattern that seems to be wrong. It could be a mistake. I would register the problem at https://connect.microsoft.com/ .

In the meantime, you can just set MonthDayPattern ....

 Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-au", false); System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern.Dump(); System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthDayPattern.Dump(); DateTime.Parse("1/5").Dump(); System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthDayPattern = "d MMMM"; DateTime.Parse("1/5").Dump(); 

In Windows Server 2012 R2:

d / MM / YYYY

MMMM d

01/05/2016 12:00:00 AM

05/01/2016 12:00:00 AM

+2
source

All Articles