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

namespace Edu.Common
{
    /// <summary>
    /// 类型转换帮助类
    /// </summary>
    public static class ConvertHelper
    {
        /// <summary>
        /// 格式化时间【yyyy-MM-dd HH:mm:ss】
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static string FormatTime(this object time)
        {
            string timeStr = "";
            if (time != null)
            {
                try
                {
                    timeStr = Convert.ToDateTime(time.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch
                { 
                
                }
            }
            return timeStr;
        }

        /// <summary>
        /// 格式化时间【yyyy-MM-dd HH:mm:ss】
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static string FormatDate(object time)
        {
            string timeStr = "";
            if (time != null)
            {
                try
                {
                    timeStr = Convert.ToDateTime(time.ToString()).ToString("yyyy-MM-dd");
                }
                catch
                {

                }
            }
            return timeStr;
        }
    }
}