I am kind of stuck with an issue where I am unable to to parse the date and time from a string, which I am reading from a text file. The string I am getting is in following format:
05SEP1998 2400
and I am trying to parse the string through the following code:
string dateTimeStr = "05SEP1998 2400"
var provider = CultureInfo.InvariantCulture;
const string Format = "ddMMMyyyy hhmm";
var dateTime = DateTime.ParseExact(dateTimeStr, Format, provider);
But while parsing, the above code throws a FormatException:
String was not recognized as a valid DateTime.
Could anybody please help me fixing this issue?