public static string FormatTimeSpecific(DateTime dateValue, string formatString) { formatString = formatString.Replace(".", ":").Replace("-", ":").Replace(",", ":"); if (dateValue != null && (typeof(DateTime) == dateValue.GetType())) { return(dateValue.Format(formatString)); } else { return(""); } }