Home All Groups Group Topic Archive Search About

A design question about format provider

Author
7 Mar 2007 8:06 PM
Nick nkw
I am building an asp.net application. However, it had to use a lot of
Convert.ToDatetime or Parse. And I had a lot of the following code:

IFormatProvider provider = new
CultureInfo(ConfigurationManager.AppSettings.Get("culture"));
.... DateTime.Parse(lblDate.Text, provider)...
.... Convert.ToDateTime(..., provider)....

Is refactoring the one line to an singleton worth? Sounds it save a little
bit typing.

Author
8 Mar 2007 4:22 PM
bruce barker
the advantage of the singleton is abstraction of the method. you ca
change the formating style in one place.

-- bruce (sqlwork.com)

Nick nkw wrote:
Show quote
> I am building an asp.net application. However, it had to use a lot of
> Convert.ToDatetime or Parse. And I had a lot of the following code:
>
> IFormatProvider provider = new
> CultureInfo(ConfigurationManager.AppSettings.Get("culture"));
> .... DateTime.Parse(lblDate.Text, provider)...
> .... Convert.ToDateTime(..., provider)....
>
> Is refactoring the one line to an singleton worth? Sounds it save a
> little bit typing.
>
>

AddThis Social Bookmark Button