CultureInfo For Swedish

Manoj Sethi picture Manoj Sethi · Dec 27, 2013 · Viewed 18k times · Source

I want to convert the datetime to Swedish Culture.

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

Above line of code gives me results as 27 December 2013

I want to have results which display december in swedish language.

Answer

Dmitry Bychenko picture Dmitry Bychenko · Dec 27, 2013

You should use Swedish Culture for that:

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

If Swedish should be used in each ToString() you can set up CurrentCulture:

  // Or/And CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("sv-SE");
  Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("sv-SE");
  ...

  // Since Current Culture is Swedish, there's no need to put it explicitly
  DateTime.Now.ToString("dd MMMM yyyy");