goja-core/src/main/java/goja/core/kits/IdCardKit.java
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);
            }
            // 获取出生年(完全表现形式,如：2010)
            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;
    }
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);
            }
            // 获取出生年(完全表现形式,如：2010)
            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;
    }
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 ) ; } // 获取出生年(完全表现形式,如：2010) 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 ; }
将15位身份证号码转换为18位

@param idCard 15位身份编码
@return 18位身份编码
将15位身份证号码转换为18位