public static boolean isRsdnNum(String strRsdn) { String strRsdnNum = strRsdn.replaceAll("[^0-9]", ""); if(strRsdnNum.length() != 13) return false; int yy = Integer.parseInt(strRsdnNum.substring(0, 2)); int mm = Integer.parseInt(strRsdnNum.substring(2, 4)); int dd = Integer.parseInt(strRsdnNum.substring(4, 6)); if(yy < 1 || yy > 99 || mm > 12 || mm < 1 || dd < 1 || dd > 31) return false; float sum = (Float.parseFloat(strRsdnNum.substring(0, 1)) * 2) + (Float.parseFloat(strRsdnNum.substring(1, 2)) * 3) + (Float.parseFloat(strRsdnNum.substring(2, 3)) * 4) + (Float.parseFloat(strRsdnNum.substring(3, 4)) * 5) + (Float.parseFloat(strRsdnNum.substring(4, 5)) * 6) + (Float.parseFloat(strRsdnNum.substring(5, 6)) * 7) + (Float.parseFloat(strRsdnNum.substring(6, 7)) * 8) + (Float.parseFloat(strRsdnNum.substring(7, 8)) * 9) + (Float.parseFloat(strRsdnNum.substring(8, 9)) * 2) + (Float.parseFloat(strRsdnNum.substring(9, 10)) * 3) + (Float.parseFloat(strRsdnNum.substring(10, 11)) * 4) + (Float.parseFloat(strRsdnNum.substring(11, 12)) * 5); if(Float.parseFloat(strRsdnNum.substring(12, 13)) != (11 - (sum % 11)) % 10) return false; return true; }
//법인번호 체크
public static boolean isCorporNum(String strCorpor) { String strCorporNum = strCorpor.replaceAll("[^0-9]", ""); if(strCorporNum.length() != 13) return false; float sum = 0; for (int i=0; i < 12; i++) sum += ((i % 2) + 1) * Float.parseFloat(String.valueOf(strCorpor.charAt(i))); if (Float.parseFloat(strCorporNum.substring(12, 13)) != (10 - (sum % 10)) % 10) return false; return true; }
댓글 없음:
댓글 쓰기