Reputation: 35
Im unable to use the function parseexact to transform the following String to Date
This one works:
Dim fechaS = "Feb 16 23:13:53.241 2015"
fecha1 = DateTime.ParseExact(fechaS, "MMM dd HH:mm:ss.fff yyyy", Nothing)
But fails, when I add a couple more options:
Dim fechaS = "Mon 16 23:13:53.241 UTC 2015"
fecha1 = DateTime.ParseExact(fechaS, "ddd MMM dd HH:mm:ss.fff z yyyy", Nothing)
Upvotes: 1
Views: 498
Reputation: 27322
Your second example has three issues with it:
z
signifies) . You could to this by replacing UTC
with +0
This fails
Dim fechaS = "Mon 16 23:13:53.241 UTC 2015"
fecha1 = DateTime.ParseExact(fechaS, "ddd MMM dd HH:mm:ss.fff z yyyy", Nothing)
This works
Dim fechaS = "Mon Feb 16 23:13:53.241 UTC 2015"
fecha1 = DateTime.ParseExact(fechaS.Replace("UTC", "+0"), "ddd MMM dd HH:mm:ss.fff z yyyy", Nothing)
More info here on the date time formats allowed: Custom DateTime Format Strings
Upvotes: 2