Internationalization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an application that could be hosted in a number of countries. I need
to detect the user locale and then accept dates as input for that locale eg
13.01.2004 for germany and 1/13/2004 for the USA. The date should then be
reformatted to match the locale settings for the country hosting the
application, so that the correct date is inserted into the (oracle) database.

What is the simplest way to achieve this?
 
rufus said:
I have an application that could be hosted in a number of countries. I need
to detect the user locale and then accept dates as input for that locale eg
13.01.2004 for germany and 1/13/2004 for the USA. The date should then be
reformatted to match the locale settings for the country hosting the
application, so that the correct date is inserted into the (oracle) database.

Note - you shouldn't be formatting the date at all for insertion into
the database. You should be using parameterised insert statements and
setting the values of the parameters, rather than giving the dates in
any kind of text form.
What is the simplest way to achieve this?

For parsing, use Date.Parse and pass in the appropriate CultureInfo, eg
CultureInfo.CurrentCulture or CultureInfo.CurrentUICulture.
 
Take in to account the databases (at least SQL Server) adapts to locale
at installation time too (takes on defaults based on locale especially when
it comes to date/time). With SQL though (although I understand you're using
Oracle) the underlying storage format is always the same - don't confuse it
with the display format).
 
Back
Top