阅读877 返回首页    go 阿里云 go 技术社区[云栖]


C#返回以数字日期编号为日期函数

/// <summary>
/// 返回以数字日期编号为日期函数
/// </summary>    
/// <returns>日期编号</returns>
public DateTime GetCodeToDate(string MyDateCode)
{
    try // 正常运行
    {
        String strYear = MyDateCode.Substring(0, 4);
        String strMonth = MyDateCode.Substring(4, 2);
        String strDay = MyDateCode.Substring(6, 2);
        // 返回日期
        return Convert.ToDateTime(strYear.ToString() + "-" + strMonth.ToString() + "-" + strDay.ToString());
    }
    catch (System.Exception Exp) // 异常处理
    {
        // 异常信息
        System.Diagnostics.Debug.Write(Exp.Message.ToString());
        // 返回日期
        return DateTime.Today;
    }
}

我有几张阿里云幸运券分享给你,用券购买或者升级阿里云相应产品会有特惠惊喜哦!把想要买的产品的幸运券都领走吧!快下手,马上就要抢光了。
https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=6evata1e&utm_source=6evata1e

最后更新:2017-10-08 21:03:02

  上一篇:go 图说一周财经大事:云栖大会召开 上市公司三季报启幕
  下一篇:go  【文档】四、Mysql Binlog事件含义详解