2

my computer is set to america datetime culture dd-mm-yyyy but in my application I want to use yy-mm-dd so I want to use swedish culture no matter what the computer culture is set to. using this line dosen't always work Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE"); It's a asp.net web application.

4
  • Doesn't always work - what's the issue you're facing? Commented Aug 28, 2015 at 10:34
  • Sometimes when debugging my datetime will be dd-mm-yyyy and the next time I debug the same datetime will be yyyy-mm-dd. Commented Aug 28, 2015 at 10:38
  • @JoakimCarlsson Are you sure it is after setting a culture for a Thread? Commented Aug 28, 2015 at 10:39
  • @Kamo it works when not debugging, but when debugging it doesn't. Commented Aug 28, 2015 at 10:55

1 Answer 1

6

Setting the culture for the thread only works for code executed after that line. Also a request can be handled by different threads in different stages, so you would need to repeat that line after each point where a thread switch is possible.

To set the culture globally you can specify the culture in the system.web section in web.config:

<globalization culture="sv-SE" uiCulture="sv-SE" /> 
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this would have helped be a long time ago. Thanks for the fast reply.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.