0

I would like to ask if it is a good coding practice to manually set the YearMonthPattern of the CurrentCulture? My problem is I set the current culture to Invariant, and the YearMonthPattern changed.

What I did is just added the code to set the YearMonthPattern just after setting the Cultures.

//Set Cultures
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(127);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(127);
//Set Year Month Pattern
System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.YearMonthPattern = "MMMM, yyyy";
KaeL
  • 3,639
  • 2
  • 28
  • 56

1 Answers1

1

I can't see anything wrong with it. It's just that it might not be conform to the actual culture pattern but if that's how you want years to be displayed it is OK.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Thanks Darin. Before I'm not setting the Cultures, and by default it was set to `English (United States)`. But I got issue when I'm not setting the cultures, so I came up with initializing it and found this `Invariant Culture` (which I think is the default one). And later, this `YearTimePattern` was changed. I guess I'll stick with my code above. Thanks :D – KaeL Jul 12 '11 at 02:29