根据身份证号提取出生日期

 public static string BirthDate(string idNO)         {             try             {

                string strYear = string.Empty;                 string strMonth = string.Empty;                 string strDay = string.Empty;                 string strBirtyDate = string.Empty;                 if (idNO.Length == 18)                 {                     strYear = idNO.Substring(6, 4) + "年";                     strMonth = idNO.Substring(10, 2) + "月";                     strDay = idNO.Substring(12, 2) + "日";                     strBirtyDate = strYear + strMonth + strDay;                     return strBirtyDate;                 }                 else if (idNO.Length == 15)                 {                     strYear = "19" + idNO.Substring(6, 2) + "年";                     strMonth = idNO.Substring(8, 2) + "月";                     strDay = idNO.Substring(10, 2) + "日";                     strBirtyDate = strYear + strMonth + strDay;                     return strBirtyDate;                 }                 else                 {                     return "身份证位数不正确";                 }             }             catch (Exception ex)             {                 throw new Exception("身份证号传输错误" + ex.Message);             }         }

posted @ 2013-12-30 16:33  心兰月湾  阅读(197)  评论(0编辑  收藏  举报