Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Reading PT0S to 0 second using C#

I have an XML file giving me the value PT0S.

 <Property name="TargetQuantity" type="double">
        <Value>PT0S</Value>
 </Property>

I have to store this value in a DATABASE table field – which is of type decimal. I have no idea how to convert this value to decimal. I am using C# to process this value.
I tried to use

Convert.ToDecimal

But it does not work.
Any advices would be helpful.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can’t directly convert a timespan to a decimal. You need to decide which property you want.

See How do I convert an ISO8601 TimeSpan to a C# TimeSpan? (XmlConvert.ToTimeSpan(string)), and then for example save TimeSpan.TotalSeconds in your decimal column.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading