Converting String to DateTime
The Parse method is used to convert a string to a DateTime object. The string passed on the Parse method must have a correct DateTime format. Conversion from a DateTime to a string is done using the ToString() method.
The code snippet in Listing 15 converts a string to a DateTime.
Private Sub ConcertStringToDateTime()
Dim dt As String = "2010-10-04T20:12:45-5:00"
Dim newDt As DateTime = DateTime.Parse(dt)
Console.WriteLine(newDt.ToString())
End Sub
No comments:
Post a Comment