Converts String to a DateTimeOffset, use more than one format
Imports System
Imports System.Xml
Module Module1
Sub Main()
Dim reader As XmlReader = XmlReader.Create("myData.xml")
reader.ReadToFollowing("time")
Dim time As String = reader.ReadElementContentAsString()
Dim formats As String() = {"yyyy-MM-ddTHH:mm:sszzzzzzz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-dd"}
Try
Dim transaction_time As DateTimeOffset = XmlConvert.ToDateTimeOffset(time, formats)
Console.WriteLine(transaction_time)
Catch e As Exception
Console.WriteLine(e)
End Try
End Sub
End Module
Related examples in the same category