C#支持从自定义日期时间格式到DateTime类型
/// <summary>
///
/// </summary>
/// <param name="orignalData">20110122</param>
/// <returns></returns>
private string ConverterRISDateToValidDate(string orignalData)
{
string result = "";
DateTime dtResult = new DateTime();
bool isRight = DateTime.TryParseExact(orignalData, @"yyyyMMdd", null, DateTimeStyles.None, out dtResult);
if (isRight)
{
result = dtResult.ToShortDateString();
}
return result;
}
/// <summary>
///
/// </summary>
/// <param name="orignalData">13:55.000</param>
/// <returns></returns>
private string ConverterRISTimeToValidTime(string orignalData)
{
string result = "";
DateTime dtResult = new DateTime();
bool isRight = DateTime.TryParseExact(orignalData, @"HHmmss.fff", null, DateTimeStyles.None, out dtResult);
if (isRight)
{
result = dtResult.ToShortTimeString();
}
return result;
}
https://muzizongheng.blog.csdn.net/