datetime - Is CurrentUICulture.DateTimeFormat different on OS and .NET version? -


i ran following code on 2 different pc's

string info = string.format("clr ver. {0}, culture name: {1},  shortdatepattern: {2}", environment.version, thread.currentthread.currentuiculture.displayname, thread.currentthread.currentuiculture.datetimeformat.shortdatepattern); 

on windows server 2008 r2 .net 3.5, value of info

clr ver. 2.0.50727.5485, culture name: english (canada), shortdatepattern: dd/mm/yyyy

however, on windows server 2012 .net 4.5, value is

clr ver. 4.0.30319.34209, culture name: english (canada), shortdatepattern: yyyy-mm-dd

i wondering why currentuiculture.datetimeformat dependent on .net version?? breaking change in .net4.5?

you correct default short-date format en-ca changed, of .net 4.0. can test yourself:

console.writeline(new cultureinfo("en-ca").datetimeformat.shortdatepattern); 

running on .net 2 runtime (framework 2.0/3.x) give "dd/mm/yyyy". running on .net 4 runtime (framework 4.x) give "yyyy-mm-dd".

this described in msdn document: what's new in globalization , localization. few cultures listed in example table, there many others updated, including en-ca.

also might want check date/time settings in windows control panel. it's possible 1 of machine's settings has been customized. carry through current culture's format settings.

also, date/time format changes come through currentculture. currentuiculture resource string lookup via .resx files.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -