using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.UI.BllCommon
{
    /// <summary>
    /// 系统使用固定的方式去转换时间S
    /// </summary>
   public  class DateTimeManager
    {
        public static DateTime ConvertDateTime(string timeStr)
        {
            string format = "yyyyMMdd";
            if (timeStr.Length > 8)
            {
                format = "yyyyMMddHHmmss";
            }
            DateTime dateTime = DateTime.ParseExact(timeStr, format, System.Globalization.CultureInfo.InvariantCulture);
            return dateTime;
        }
        public static DateTime ConvertDateTimeH(string timeStr)
        {
            string format = "yyyy-MM-dd";
            DateTime dateTime = DateTime.Now;
            if (string.IsNullOrEmpty(timeStr))
            {
                return dateTime;
            }

            try
            {
                 dateTime = DateTime.ParseExact(timeStr, format, System.Globalization.CultureInfo.InvariantCulture);
            }
            catch (Exception ex)
            {
            }
            return dateTime;
        }
        public static string ConvertDateTime(DateTime dateTime)
        {         
            return dateTime.ToString("yyyyMMddHHmmss");
        }
    }
}
