VB.Net Tutorial/Date Time/Date Parse

Материал из VB Эксперт
Перейти к: навигация, поиск

Parse Date

Public Class Tester
    Public Shared Sub Main
        Dim dateParse As Date = Date.Parse("December 25, 2007")

        Console.WriteLine(dateParse)
    End Sub

End Class
25/12/2007 12:00:00 AM

Parse Date: 59

Public Class Tester
    Public Shared Sub Main
        Dim testDate As String
        Dim results As New System.Text.StringBuilder
        " ----- Test a standardized date and time.
        testDate = "2007-07-04T23:59:59"
        If (IsDate(testDate) = True) Then _
           results.AppendLine(Date.Parse(testDate).ToString)
        Console.WriteLine(results.ToString())
    End Sub
End Class
04/07/2007 11:59:59 PM

Parse Date: 59Z

Public Class Tester
    Public Shared Sub Main
        Dim testDate As String
        Dim results As New System.Text.StringBuilder
        " ----- Test another standardized UTC date and time.
        testDate = "2007-07-04T23:59:59Z"
        If (IsDate(testDate) = True) Then _
           results.AppendLine(Date.Parse(testDate).ToString)
        Console.WriteLine(results.ToString())
    End Sub
End Class
04/07/2007 4:59:59 PM

==Parse Date: /td>


Public Class Tester
    Public Shared Sub Main
        Dim testDate As String
        Dim results As New System.Text.StringBuilder
        " ----- Test a time.
        testDate = "23:57:58"
        If (IsDate(testDate) = True) Then _
           results.AppendLine(Date.Parse(testDate).ToString)
        Console.WriteLine(results.ToString())
    End Sub
End Class
11/05/2007 11:57:58 PM

Parse Date: December 7, 2007

Public Class Tester
    Public Shared Sub Main
        Dim testDate As String
        Dim results As New System.Text.StringBuilder
        " ----- Test a date.
        testDate = "December 7, 2007"
        If (IsDate(testDate) = True) Then _
           results.AppendLine(Date.Parse(testDate).ToString)
        Console.WriteLine(results.ToString())
    End Sub
End Class
07/12/2007 12:00:00 AM

Parse Date: Feb 3, 2007

Public Class Tester
    Public Shared Sub Main
        Dim testDate As String
        Dim results As New System.Text.StringBuilder

        testDate = "Feb 3, 2007"
        If (IsDate(testDate) = True) Then _
           results.AppendLine(Date.Parse(testDate).ToString)
        Console.WriteLine(results.ToString())
    End Sub
End Class
03/02/2007 12:00:00 AM