Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.50 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. datetime.parse failing for march in Spanish, every other month works
  2. [Test]
  3. [ExpectedException(typeof(FormatException), ExpectedMessage = "String was not recognized as a valid DateTime.")]
  4. public void ParsingWithAbbreviatedSpanishMarchBlowsUp()
  5. {
  6.    var dt = DateTime.Parse("15-mar-2012", CultureInfo.GetCultureInfo("es-ES"), DateTimeStyles.None);
  7. }
  8.        
  9. var format = "dd-MMM-yyyy";
  10. var input= "15-mar-2012";
  11. var dt = DateTime.ParseExact(input, format, new CultureInfo("es-ES"));
  12. Console.WriteLine(dt);