DateTime.ParseExact problems while parsing a ddMMMyyyy string.

  • Thread starter Thread starter Morieky
  • Start date Start date
M

Morieky

Guest
TL;DR : Trying to parse string to datetime using ParseExact where string = "01ENE2019" , format = "ddMMMyyyy" and culture is es-ES.This does work in my vb6 proyect.After rewriting it for c# in .net framework 4.5.2 it just returns format error.

Im trying to parse a string using DateTime.ParseExact like this

=> someVar= DateTime.ParseExact(dateString, "ddMMMyyyy", myCulture);

Where:
- dateString has been tested as 01ENE2019, 01Ene2019, 15MAR2019 and 15Mar2019.
- myCulture had 1 of these values during all iterations.
myCulture = System.Globalization.CultureInfo.CreateSpecificCulture("es-ES");
myCulture = System.Globalization.CultureInfo.CreateSpecificCulture("ES-es");
mCulture = System.Globalization.CultureInfo.InvariantCulture;
myCulture = null;

I'm just getting a parse error. It says it can`t parse the date because it isnt't able to recognize the format.

Here you have a dotnetfiddle with an small example of the problem i'm having.

BravoTimeError | C# Online Compiler | .NET Fiddle

Continue reading...
 
Back
Top