How to set date time format as "MM/DD/YYYY" for the entire application (including referring dlls)
-
Hi I have tried the following code in Form's constructor
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
but it doesn't work in other dlls which are used by the applicaiton (form). How to achieve this? Thanks srini -
Hi I have tried the following code in Form's constructor
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
but it doesn't work in other dlls which are used by the applicaiton (form). How to achieve this? Thanks sriniI typically set the
Application.CurrentCulture
property in addition to the thread properties. Are you sure that the DLLs make use of the thread's culture settings? Maybe their localisation is hard-coded or they utilize the OS culture (CultureInfo.InstalledUICulture
).Regards, Tim
-
I typically set the
Application.CurrentCulture
property in addition to the thread properties. Are you sure that the DLLs make use of the thread's culture settings? Maybe their localisation is hard-coded or they utilize the OS culture (CultureInfo.InstalledUICulture
).Regards, Tim
Hi How can we make sure the dlls are using thread's culture settings? We just created dlls without touching any culture informations. But our OS is running on UK culture, thats why it is dispalying in DD/MM/YYYY format Actually in my application i have some calendar controls where it is displaying US format (after i made that culture change), but the data which i am getting from other dlls are in "DD/MM/YYYY" format! I thought changing the culture info of current thread will impact the referring dlls is it correct? Thanks srini
-
Hi I have tried the following code in Form's constructor
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
but it doesn't work in other dlls which are used by the applicaiton (form). How to achieve this? Thanks sriniYou should not force your culture on a client. The client's system settings should be used. If you must force a date/time format it should be ISO 8601.
-
You should not force your culture on a client. The client's system settings should be used. If you must force a date/time format it should be ISO 8601.
-
no.... all our application is following US datetime format.. if somebody installed OS on UK culture.. then our application must send the datetime in US format irrelevant of system culture. Thats why we need to do this change.
Too bad - then your application has been developed by some pretty incompetent people. Your program should always use DateTime objects internally. If it needs to represent the date as a string, then do it using the ISO format mentioned. Preferably the internal format is UTC as well, unless there is an extremely good reason for it to be kept in local time. Various user interface controls (like your calender) should map to the users culture without problems (if it doesn't, ditch it and use something better). When interfacing the non-ISO system, encode to and from the specific format at the interface point - never let the bad format requiremen polute your internal program structure, and above all, never EVER let it polute the user interface.