By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,213 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,213 IT Pros & Developers. It's quick & easy.

Setting DateTime.Parse( ) default IFormatProvider

P: n/a
Consider an application which has *many* references to

DateTime.Parse(string);

Is there a way, say when the application first starts up to force this
method to use a specific IFormatProvider, so every
DateTime.Parse(string) is really

DateTime.Parse(string, format);

(where format is defined once)

Now you might be saying 'thats easy, just go and set your Regional
settings to whatever format you want'. Unfortunatly that is beyond my
control since the application is deployed to many clients. You might
also say, 'find every instance of DateTime.parse(string) and replace
with DateTime.Parse(string, format). I only really want to do that if
forced to because

a) there is many many places i have to do this
b) Other programmers have to remember to do this each time they do a
DateTime.Parse( )

I'm hoping there is something like

System.SetDefaultIFormatProvider(myFormat);
:D

Regards
--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You can do:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-AU");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-AU");

but unfortunately child threads dont inherit this property so not a
solution

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.