I need to parse dates and times from strings. The Problem is that the strings can have any possible format. But I also get the format strings.
So i get:
Date = "9/15/2010" Time = "16:12:45" DateFormat = "M/dd/yyyy" TimeFormat = "h:mm:ss" TimeZone = "+2:00:00" // +/- and time in TimeFormat
But i have some problems parsing these strings.
I can't parse the time
does not work and causes a FormatException. What is wrong with this call?
If the DateFormat contains slashes, i need to escape them
@"M\/dd\/yyyy". Are there any other chars that would need escaping?
Can i parse the whole DateTime in one? Somehting like:
DateTime.ParseExact(Date+' '+Time+' '+TimeZone,DateFormat+' '+TimeFormat+' +'+TimeFormat,null,DateTimeStyles.None);