软件编程
位置:首页>> 软件编程>> C#编程>> 自定义时间格式转换代码分享

自定义时间格式转换代码分享

  发布时间:2022-11-03 03:09:23 

标签:时间格式转换


/// <summary>
        /// 将日期字符串转换为日期类型
        /// </summary>
        /// <param name="strDateTime">形如"2012年5月14日"的日期字符串</param>
        private DateTime ParseDateTime(string strDateTime)
        {
            ////Like: string strDateTime = "2012年5月14日";
            DateTime dateTime;
            if (DateTime.TryParseExact(strDateTime, "yyyy年M月d日", new System.Globalization.CultureInfo("en-US"), System.Globalization.DateTimeStyles.AssumeLocal, out dateTime))
            {
                return dateTime;
            }
            else
            {
                return DateTime.Today;
            }
        }

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com