IdCardKit { public static boolean validateTWCard(String idCard) { String start = idCard.substring(0, 1); String mid = idCard.substring(1, 9); String end = idCard.substring(9, 10); Integer iStart = twFirstCode.get(start); Integer sum = iStart / 10 + (iStart % 10) * 9; char[] chars = mid.toCharArray(); Integer iflag = 8; for (char c : chars) { sum = sum + Integer.valueOf(c + "") * iflag; iflag--; } return (sum % 10 == 0 ? 0 : (10 - sum % 10)) == Integer.valueOf(end); }  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 testValidateTWCard() throws Exception { }