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;
        }
posted @ 2013-07-02 13:09  muzizongheng  阅读(303)  评论(0编辑  收藏  举报
如果我们时时忙着展现自己的知识, 将何从忆起成长所需的无知?