zoukankan      html  css  js  c++  java
  • 通过身份证号码取得生日的一段代码(支持18位和15位身份证)

        /// <summary>
        /// 根据身份证号码取得生日
        /// </summary>
        /// <param name="cardID">身份证号码</param>
        /// <returns>生日</returns>
        public string GetBirthday(string cardID)
        {
            string birthday;
            if (cardID.Length == 18)
            {
                string str_year = cardID.Substring(6, 4);
                string str_month = cardID.Substring(10, 2);
                string str_day = cardID.Substring(12, 2);

                int year = Convert.ToInt16(str_year);
                int month = Convert.ToInt16(str_month);
                int day = Convert.ToInt16(str_day);
                if ((year > 1800 && year < 2500) && (month <= 12) && (day <= 31))
                {
                    birthday = year.ToString() + "年" + month.ToString() + "月" + day.ToString() + "日";
                    return birthday;
                }
                else
                {
                    RegisterStartupScript("提示", "<script> alert('获取生日时出错!')</script>");
                    return null;
                }
            }
            else
            {
                string str_year = cardID.Substring(6, 2);
                string str_month = cardID.Substring(8, 2);
                string str_day = cardID.Substring(10, 2);

                int year = Convert.ToInt16(str_year);
                int month = Convert.ToInt16(str_month);
                int day = Convert.ToInt16(str_day);
                if ((month <= 12) && (day <= 31))
                {
                    birthday = "19" + year.ToString() + "年" + month.ToString() + "月" + day.ToString() + "日";
                    return birthday;
                }
                else
                {
                    RegisterStartupScript("提示", "<script> alert('获取生日时出错!')</script>");
                    return null;
                }
            }
        }

  • 相关阅读:
    分析drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
    osg求交,模型矩阵
    Opengl RC(Render context,渲染上下文)与像素格式
    osg渲染属性和opengl的接口分析
    opengl累积缓存
    weekly review 200946: NON Memory
    推荐:每周影评2009国产电影回顾
    [Study Note] Dependency Injection and Inversion of Control
    [Study Note] TDD: Consistent test structure (测试代码的结构一致性)
    海淀驾校学车考证经历(二)第一次上车
  • 原文地址:https://www.cnblogs.com/88223100/p/1181225.html
Copyright © 2011-2022 走看看