I have a date string as "2017-08-08T17:08:29 EDT -0400". We are rewriting the Java App to C#. In Java by parsing this date to the SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss z Z"), the validation is done. But in C# when I try to parse it to DateTime I am getting an error as this is not a DateTime string. How can I validate this date using C#?
Thanks
I have few suggestions and questions:
I would use either EDT or -0400, not both, eg:
var s = "2017-08-08T17:08:29 -0400"; var format = "yyyy-MM-ddTHH:mm:ss zzz"; CultureInfo provider = CultureInfo.InvariantCulture; var d = DateTime.ParseExact(s, format, provider); Console.WriteLine(d);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.