Cultural Information for Swedish

I want to convert datetime to swedish culture.

DateTime.Today.ToString("dd MMMM yyyy"); 

Above line of code gives me results like December 27th, 2013

I want to get results that show December in Swedish.

+7
c # culture
source share
3 answers

You must use Swedish culture for this:

 DateTime.Today.ToString("dd MMMM yyyy", CultureInfo.GetCultureInfo("sv-SE")); 

If Swedish should be used in each ToString() , you can configure CurrentCulture:

  // Or/And CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("sv-SE"); Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("sv-SE"); ... // Since Current Culture is Swedish, there no need to put it explicitly DateTime.Now.ToString("dd MMMM yyyy"); 
+12
source share

And if you do not want to use the culture parameter all over the world, you use this method, then you can set the default application language to Swedish by doing one or more of them:

 CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("sv-SE"); CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("sv-SE"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("sv-SE"); Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE"); 

Then wherever you call your ToString() method, it will scribble according to the current culture information that you set.

+3
source share
 DateTime.Today.ToString("dd MMMM yyyy", new CultureInfo("sv-SE")); 

see here

// Creates and initializes CultureInfo, which uses an international view.

 DateTime.Today.ToString("dd MMMM yyyy",new CultureInfo("sv-SE"); 

// Creates and initializes CultureInfo, which uses traditional sorting.

 DateTime.Today.ToString("dd MMMM yyyy",new CultureInfo(0x041D); 
+1
source share

All Articles