Detilium
Detilium

Reputation: 3034

Forcing the language culture vs. date/decimal culture

I'm trying to force my application to use the english resource provided, meaning the en-EN culture. There's only one problem; I want the dates and decimals to be another culture.

I have forced the language culture by adding the following to the Web.config:

<globalization uiCulture="en" />

Is there an easy way for me to change the dates globally for the entire project, or do I need to format the date on each date input/output around my MVC proejct?

Upvotes: 0

Views: 74

Answers (1)

stylishCoder
stylishCoder

Reputation: 385

You can try to change the current thread culture in Global.asax file, and override the date format for example:

protected void Application_BeginRequest(Object sender, EventArgs e)
{    
  CultureInfo newCulture = (CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
  newCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy";
  newCulture.DateTimeFormat.DateSeparator = "-";
  Thread.CurrentThread.CurrentCulture = newCulture;
}

Upvotes: 2

Related Questions