1.身份证提起出生年月信息
注意:有15位和18位
public String idCard2Birthday(String no) {
String birthday = "";
if (no.length() == 15) {
String tempYear = no.substring(6, 8);
String tempMonth = no.substring(8, 10);
String tempDate = no.substring(10, 12);
int tempCYear = Calendar.getInstance().get(Calendar.YEAR);
tempYear = "20" + tempYear;
int itempYear = Integer.parseInt(tempYear);
if (itempYear > tempCYear) {
tempYear = "19" + tempYear.substring(2);
}
birthday = tempYear + "-" + tempMonth + "-" + tempDate;
} else if (no.length() == 18) {
String tempYear = no.substring(6, 10);
String tempMonth = no.substring(10, 12);
String tempDate = no.substring(12, 14);
birthday = tempYear + "-" + tempMonth + "-" + tempDate;
}
return birthday;
}