开发者

Manually set Culture Info Year Time Pattern

开发者 https://www.devze.com 2023-03-19 13:50 出处:网络
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.

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.DateT开发者_开发百科imeFormat.YearMonthPattern = "MMMM, yyyy";


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消