Pregunta

I'm having trouble Converting "05:10:15D+0" to DateTime. Reuters has the datatype as "bftime" and time is in GMT/UTC.

I don't want to substring it as I have Multiple Market Data Providers which send this value as only Date if the markets have not opened up.

Following is the way I'm trying to convert.ToDateTime

MDLastTick =  Convert.ToDateTime(LastTick);

Exception:

The string was not recognized as a valid DateTime. There is a unknown word starting at index 8.

¿Fue útil?

Solución 2

You could use this regexp to just grab out the time component: \d{1,2}:\d{1,2}:\d{1,2} (Or just use the first 8 characters as a substring) - and then datetime.parse the matching time. You know it's always UTC so you can ignore the D+0.

This is however just a time, not a datetime.

Otros consejos

What you have is not a datetime as it's missing the date part. You only have time, so consider using TimeSpan.Parse.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top