IdCardKit { public static boolean validateIdCard15(String idCard) { if (idCard.length() != CHINA_ID_MIN_LENGTH) { return false; } if (isNum(idCard)) { String proCode = idCard.substring(0, 2); if (cityCodes.get(proCode) == null) { return false; } String birthCode = idCard.substring(6, 12); Date birthDate = null; try { birthDate = new SimpleDateFormat("yy").parse(birthCode.substring(0, 2)); } catch (ParseException e) { e.printStackTrace(); } Calendar cal = Calendar.getInstance(); if (birthDate != null) { cal.setTime(birthDate); } if (!valiDate(cal.get(Calendar.YEAR), Integer.valueOf(birthCode.substring(2, 4)), Integer.valueOf(birthCode.substring(4, 6)))) { return false; } } else { return false; } return true; }  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; }
@Test public void testValidateIdCard15() throws Exception { }