I receive a date-time from automation system like this: 00:00:30:00.
When I try to parse it to TimeSpan I get this error:
Input string was not in a correct format.
What kind of format can help me to convert this to TimeSpan?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Decent TimeSpan parsing is only available in .NET 4.0. For earlier version you can hijack the DateTime parsing methods, converting from a date to a timespan through the Ticks property. Like this:
Additional work is required when you need to parse negative time spans.