DateTime.TryParseExact 万能时间格式转化 DateTime.TryParse

 

  private DateTime convertDASTime(string s)
        {
            DateTime result;
            if (DateTime.TryParseExact(s, "yyyyMMddHHmmss", null, System.Globalization.DateTimeStyles.None, out result))
            {
                return result;
            }
            return DateTime.ParseExact(s, "yyyyMMddHHmmssfff", System.Globalization.CultureInfo.CurrentCulture);
        }

 

posted on 2020-07-15 09:39  红磨坊后的白桦树  阅读(344)  评论(0编辑  收藏  举报