title: How to convert double value to a time? C#/ASP.NET
body: <p>How can I convert <code>double</code> value to time?
  for example I have this <code>double</code> value 
  <code>val = 0.00295692867015203</code> and I want to return <code>4:15</code>.</p>
  
  <p>I have done a lot of research and did not find a solution that worked!  Here is a function that I have tried also but it returns <code>00:00:00</code>:</p>
  
  <p><code>ConvertFromDecimalToDDHHMM(Convert.ToDecimal(val));</code></p>
  
  <pre><code>public string ConvertFromDecimalToDDHHMM(decimal dHours) {
      try {
          decimal hours = Math.Floor(dHours); //take integral part
          decimal minutes = (dHours - hours) * 60.0M; //multiply fractional part with 60
          int D = (int)Math.Floor(dHours / 24);
          int H = (int)Math.Floor(hours - (D * 24));
          int M = (int)Math.Floor(minutes);
          //int S = (int)Math.Floor(seconds);   //add if you want seconds
          string timeFormat = String.Format("{0:00}:{1:00}:{2:00}", D, H, M);
  
          return timeFormat;
      }
      catch (Exception) {
          throw;
      }
  }
  </code></pre>
  
  <p>I am using <code>C#</code> and <code>ASP.NET</code>.  I will appreciate any advise.</p>