title: How to get date only if time is 00:00:00 from DateTime c#
body: <p>I want to convert  DateTime object to string. What I want to achieve is following things:</p>
  
  <ol>
  <li>Get Date only out of it if Time is 00:00:00.</li>
  <li>Get Date and Time if  both are present.</li>
  <li>I want to achieve this using <code>CurrentCulture.DateTimeFormat</code> and
  <code>Convert.ToString(DateTime, IFormatProvider)</code>, otherwise I know how
  to do this using <code>.ToString()</code> Extension method.</li>
  </ol>
  
  <p>I have tried following things:</p>
  
  <pre><code>Thread.CurrentPrincipal = principal;
  CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
  culture.DateTimeFormat.ShortDatePattern = MPAResource.DateFormat;
  culture.DateTimeFormat.LongTimePattern = "hh:mm:ss tt";
  culture.DateTimeFormat.ShortTimePattern = "hh:mm:ss tt";
  culture.DateTimeFormat.FullDateTimePattern = MPAResource.DateTimeFormat;
  Thread.CurrentThread.CurrentCulture = culture;
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>string x = Convert.ToString(x.ExpectedJoiningDate, CultureInfo.CurrentCulture);
  </code></pre>
  
  <p>Output is <code>09-Oct-2015 11:00 AM</code>. I want <code>09-Oct-2015 11:00 AM</code> if time is there and <code>09-Oct-2015</code> if time is not there.</p>
  
  <p>But above line gives me only date even if time is present with date.</p>