I have developed a MVC application for a client. Now the German branche of my client wants to use it as well. I am becoming issues about date and decimal formats. I have of course googled about culture, dataformat, number formating but cannot find a good,
solid working solution.
I want my application to work with datetime format, decimal format which I want to. For example. I have set it up into Dutch culture(‘nl-NL’) it should use always the dutch culture regardsless of the settings on the server / IIS / or the clients browser.
If i set it up for German culture(‘de-DE’). I want it to use always the german format, regardsless if it is running on the server with dutch locals.
I hope I asked the questions the correct way. Anybody a good tutorial, working solution about how to do this.
Best regards, Marcel
If you want to set culture for the entire application (not for german users only) then add following to the web.config
<configuration> <system.web> <globalization uiCulture="de-DE" culture="de-DE" /> </system.web> </configuration>
That is what i did, but still it takes the US format for numbers/decimals. In other words. I expect it to use a (,)komma for decimals and a (.) dot for thousands seperator.
For example i have two amounts
100,21 euro (one hundered euro and 21 cents)
2100,12 euro (twentyone hundered euro and 12 cents.
what my app does is converts it to
20021 euro and 210012 euro. So it thinks there are no cents there. How can i make sure that for decimals the dots and commas are rightly set. It does not see it as european notation but as american notation.
Make sure that culture is not changed somewhere. E.g. put following to the view to see the output
You can also parse decimals using specific culture
decimal d = Convert.ToDecimal("text", new System.Globalization.CultureInfo("de-DE"));
decimal d = Convert.ToDecimal("text", System.Globalization.CultureInfo.CurrentCulture); // current culture is german