문제

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.

도움이 되었습니까?

해결책 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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top