2

I am using x.CreatedDate.ToString("dd MMM") with the culture sk-SK and cz-CZ and both are returning Roman numerals for the medium month names.

The other cultures I've used with this solution work fine.

Any ideas?

Edit: adding code examples.

siteCultureInfo = CultureInfo.CreateSpecificCulture("sk-SK");
Thread.CurrentThread.CurrentUICulture = siteCultureInfo;
Thread.CurrentThread.CurrentCulture = siteCultureInfo;
string foo = x.CreatedDate.ToString("dd MMM");

Actual output where x = 13. 6. 2011 16:30:21 is 13 VI It should be 13 jún

3
  • 2
    Provide some your code , your current result and desire output.
    – dotnetstep
    Jan 4, 2012 at 16:55
  • Edited to add more info. Yes August becomes VIII.
    – Pete
    Jan 4, 2012 at 17:18
  • 1
    Are you sure that this isn't how they format their dates in slovakia and the czech Republic? This does seem to be by design...
    – Chris
    Jan 4, 2012 at 17:27

1 Answer 1

2

For sk-SK and cs-CZ it seems that the expected behaviour of MMM in a custom date format is to return the roman numeral since this is how it is defined in that date format. I can't guarantee but I assume this is because that is the commonly used abbreviation in those countries.

You can always try using .ToString("dd MMMM") which gives the full month name. Other than this there will be no "out of the box" solutions since this is how MS and thus the .NET framework think it works.

The last resort is to post-process the generated string and when it returns the Numeral version you can substitute it with the abbreviated month name that you want.

4
  • I wondered the same myself but this link would indicate otherwise publib.boulder.ibm.com/infocenter/forms/v3r5m1/… - not exactly a perfect resource for this though - do you have a source for defining sk-SK medium date format as using Roman numerals? It is certainly the answer that makes the most sense.
    – Pete
    Jan 4, 2012 at 17:42
  • Well, the fact is that is how it is defined in .NET (and I assume you don't need telling that what IBM says is going to have no effect on MS). Whether right or wrong though as I see it you either use the full name with MMMM or do some post processing on it.
    – Chris
    Jan 4, 2012 at 17:45
  • OK so we take as a given that based on the output of the above code, that is how MS defines it? I just want to be sure I haven't missed something.
    – Pete
    Jan 4, 2012 at 17:46
  • I don't have anything to link to for what I said. I just examined the CultureInfo object after creation to look at siteCultureInfo.DateTimeFormat.AbbreviatedMonthNames which lists the roman numerals. I spent a while looking to see if I could find somewhere on MSDN that confirmed this but sadly I couldn't. You can of course verify this yourself now though. :) And no, you haven't missed anything as far as I can see.
    – Chris
    Jan 4, 2012 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.