I propose to clone the culture and redefine the new monthly names in it:
var swedish = CultureInfo.GetCultureInfo("sv-SE"); swedish = (CultureInfo)swedish.Clone(); swedish.DateTimeFormat.MonthNames = swedish.DateTimeFormat.MonthNames .Select(m => swedish.TextInfo.ToTitleCase(m)) .ToArray(); swedish.DateTimeFormat.MonthGenitiveNames = swedish.DateTimeFormat.MonthGenitiveNames .Select(m => swedish.TextInfo.ToTitleCase(m)) .ToArray();
and then use it in the string.Format method:
// date holds "Mars" var date = String.Format(swedish, "{0:MMMM}", DateTime.Now);
To make the months in uppercase, I use the TextInfo.ToTitleCase method.
Alex
source share