Jhon S
Jhon S

Reputation: 31

String to DateTime conversion in .NET compact Framework

I am using .NET compact Framework, more precisely using Windows mobile 6.0 and was trying to convert a string to datetime but seems it is not supported. Any help would be appreciated.

Dim provider AS CultureInfo = New CultureInfo("en-US")
Dim dt AS DateTime = Convert.ToDatetime("5/2/2013 5:15:03 PM") 

Getting a formatexception issue.

Upvotes: 0

Views: 270

Answers (1)

devlin carnate
devlin carnate

Reputation: 8592

Please see the following .NET Fiddle here.

Imports System
Imports System.Globalization

Public Module Module1
    Public Sub Main()
        Dim provider AS CultureInfo = New CultureInfo("en-US")
        Dim dt AS DateTime = Convert.ToDatetime("5/2/2013 5:15:03 PM") 
        Console.WriteLine(dt)
        Console.WriteLine(dt.ToString("d",provider))
    End Sub
End Module

Output:

output

Upvotes: 0

Related Questions