public static void main(String[] args) { Calendar startCal = Calendar.getInstance(); startCal.set(Calendar.YEAR, 1999); startCal.set(Calendar.MONTH, 2); startCal.set(Calendar.DAY_OF_MONTH, 1); System.out.println(DateOperator.getYearDiff(startCal.getTime(), new Date())); }
/** * 因此款产品的特殊性,需要重写通用的投保人信息校验 <br> * 投保人年龄放宽到十六周岁以上即可 * * @param holder */ @Override public void commonInsHolderValidator(InsHolder holder) { commonStackholderValidator( INS_HOLDER, holder.getHolderName(), holder.getHolderPaperCat(), holder.getHolderPaperNo(), holder.getHolderBirthday(), holder.getHolderSex()); Date holderBirth = holder.getHolderBirthday(); int age = DateOperator.getYearDiff(holderBirth, new Date()); if (age < 16) { throw new IllegalArgumentException("投保人年龄不在投保范围之内"); } stackholderMobileValidator(INS_HOLDER, holder.getHolderMobile()); stackholderEmailValidator(INS_HOLDER, holder.getHolderEmail()); }