Converts the supplied String to a DateTimeOffset equivalent.
using System;
using System.Xml;
class Example
{
static void Main()
{
XmlReader reader = XmlReader.Create("transactions.xml");
reader.ReadToFollowing("time");
string time = reader.ReadElementContentAsString();
string[] formats = {"yyyy-MM-ddTHH:mm:sszzzzzzz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd"};
try
{
DateTimeOffset transaction_time = XmlConvert.ToDateTimeOffset(time, formats);
Console.WriteLine(transaction_time);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
Related examples in the same category