@Test public void testConver15CardTo18() throws Exception { }
public static String conver15CardTo18(String idCard) { String idCard18; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) { cal.setTime(birthDate); } String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); char[] cArr = idCard18.toCharArray(); int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } else { return null; } return idCard18; }
IdCardKit { public static String conver15CardTo18(String idCard) { String idCard18; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) { cal.setTime(birthDate); } String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); char[] cArr = idCard18.toCharArray(); int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } else { return null; } return idCard18; } }
IdCardKit { public static String conver15CardTo18(String idCard) { String idCard18; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) { cal.setTime(birthDate); } String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); char[] cArr = idCard18.toCharArray(); int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } else { return null; } return idCard18; }  }
IdCardKit { public static String conver15CardTo18(String idCard) { String idCard18; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) { cal.setTime(birthDate); } String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); char[] cArr = idCard18.toCharArray(); int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } else { return null; } return idCard18; }  static String conver15CardTo18(String idCard); static boolean validateCard(String idCard); static boolean validateIdCard18(String idCard); static boolean validateIdCard15(String idCard); static String[] validateIdCard10(String idCard); static boolean validateTWCard(String idCard); static boolean validateHKCard(String idCard); static int[] converCharToInt(char[] ca); static int getPowerSum(int[] iArr); static String getCheckCode18(int iSum); static int getAgeByIdCard(String idCard); static String getBirthByIdCard(String idCard); static Short getYearByIdCard(String idCard); static Short getMonthByIdCard(String idCard); static Short getDateByIdCard(String idCard); static String getGenderByIdCard(String idCard); static String getProvinceByIdCard(String idCard); }
IdCardKit { public static String conver15CardTo18(String idCard) { String idCard18; if (idCard.length() != CHINA_ID_MIN_LENGTH) { return null; } if (isNum(idCard)) { String birthday = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yyMMdd").parse(birthday); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) { cal.setTime(birthDate); } String sYear = String.valueOf(cal.get(Calendar.YEAR)); idCard18 = idCard.substring(0, 6) + sYear + idCard.substring(8); char[] cArr = idCard18.toCharArray(); int[] iCard = converCharToInt(cArr); int iSum17 = getPowerSum(iCard); String sVal = getCheckCode18(iSum17); if (sVal.length() > 0) { idCard18 += sVal; } else { return null; } } else { return null; } return idCard18; }  static String conver15CardTo18(String idCard); static boolean validateCard(String idCard); static boolean validateIdCard18(String idCard); static boolean validateIdCard15(String idCard); static String[] validateIdCard10(String idCard); static boolean validateTWCard(String idCard); static boolean validateHKCard(String idCard); static int[] converCharToInt(char[] ca); static int getPowerSum(int[] iArr); static String getCheckCode18(int iSum); static int getAgeByIdCard(String idCard); static String getBirthByIdCard(String idCard); static Short getYearByIdCard(String idCard); static Short getMonthByIdCard(String idCard); static Short getDateByIdCard(String idCard); static String getGenderByIdCard(String idCard); static String getProvinceByIdCard(String idCard); static final int CHINA_ID_MIN_LENGTH; static final int CHINA_ID_MAX_LENGTH; static final String cityCode; static final int power; static final String verifyCode; static final int MIN; static final Map<String, String> cityCodes; static final Map<String, Integer> twFirstCode; static final Map<String, Integer> hkFirstCode; }