I need parse datetimeoffsets from strings of multiple formats. One of the strings that fail is: 08/12/1992 07.00.00 -05:00
Now when I try to parse this, I use:
DateTimeOffset.ParseExact("08/12/1992 07.00.00 -05:00", "dd/MM/yyyy HH:mm:ss zzz", CultureInfo.InvariantCulture)
Which gives a FormatException:
"String was not recognized as a valid DateTime."
I can also try to add delimiters in the separators:
DateTimeOffset.ParseExact("08/12/1992 07.00.00 -05:00", "dd'/'MM'/'yyyy HH':'mm':'ss zzz", CultureInfo.InvariantCulture)
...or other permutations of small/capital letter or separators, but I get the same error.
Can anyone tell me why the ParseExact lines above do not work, and how to correct them?
EDIT: I tried using a LINQ query to replace the colon with dots (: -> .). Apparently that did not work correctly - thanks for the replies.