Converting Double to Time Format
type-conversion, vb.net
Solution
Use `DateTime.AddHours` method. It takes `double` values as a parameter:
Dim d as DateTime = (new DateTime()).AddHours(1.567)
Result is `{0001-01-01 01:34:01}`
Then you can use `DateTime.ToString()` method to get time in desired format:
Dim s as String = d.ToString("HH:mm:ss.fff")
Results is `"01:34:01.200"`
It will work for all values from `0` to `23.99`
UPDATE
If your input values represents hours and they can be greater then 24 you can use `TimeSpan` instead of `DateTime`:
Dim d as TimeSpan = TimeSpan.FromHours(220.123)
Dim s As String = string.Format("{0}:{1}:{2}.{3}", CInt(d.TotalHours), d.Minutes, d.Seconds, d.Milliseconds)
Problem
I have a bunch of numbers which I get which are like `1.567` or `22.654` or `220.123` and I want to convert them to time in the `00:00:00.000 (hours/Minutes/Seconds.Miliseconds)` Any advice on how I can achieve this efficently ?? without too much fiddling. I need a vb.net solution where possible. Thanks for the help in advance.