private string FormatTime(object DateTimeValue)
{
string result = " ";
if (DateTimeValue != null)
{
DateTime dt = DateTime.Parse(DateTimeValue.ToString());
if (dt.Hour < 10)
result = FILLER_NUMBER + dt.Hour.ToString() + ":";
else
result = dt.Hour.ToString() + ":";
if (dt.Minute < 10)
result += (FILLER_NUMBER + dt.Minute.ToString() + ":");
else
result += (dt.Minute.ToString() + ":");
if (dt.Second < 10)
result += (FILLER_NUMBER + dt.Second.ToString());
else
result += dt.Second.ToString();
}
return result;
}
Here is the refactored version::
return DateTime.Parse(DateTimeValue.ToString()).ToString("HH:mm:ss");
No comments:
Post a Comment
Be nice... it's the only internet we have.