Parse a string with time zone information
Imports System.Globalization
Class MainClass
Public Shared Sub Main()
Dim enUS As New CultureInfo("en-US")
Dim dateString As String
Dim dateValue As Date
dateString = "05/01/2009 01:30:42 PM -05:00"
Try
dateValue = Date.ParseExact(dateString, "MM/dd/yyyy hh:mm:ss tt zzz", enUS, DateTimeStyles.None)
Console.WriteLine(dateValue)
Catch e As FormatException
Console.WriteLine("'{0}' is not in an acceptable format.", dateString)
End Try
End Sub
End Class
Related examples in the same category