//使用Calendar类代表当前时间
Calendar c = Calendar.getInstance();
//examinee.getBaseInfo().getBirthday()获取前端页面输入的日期
Date ss =examinee.getBaseInfo().getBirthday();
//date转换为calendar类
Calendar cal = Calendar.getInstance();
cal.setTime(ss);
//比较年份 当前年份-输入年份大于18--已成年
Integer year = c.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
//比较月份,相同年份用月份做判断,当前月分-输入月份大于0--为未成年,负数为已成年
Integer month = c.get(Calendar.MONTH) - cal.get(Calendar.MONTH);
//比较日,相同月份,用日做判断,当前日-输入日大于0--为未成年,负数为已成年
Integer date = c.get(Calendar.DAY_OF_MONTH) - cal.get(Calendar.DAY_OF_MONTH);
//year年份大于18为已成年,month为正数且大于0且year大于18为已成年,date为正数且大于0且month为正数大于0且year大于18为已成年
if (year < 18 || month > 0 || date>0 ) {
throw new ServiceLayerException("不满18岁!");
}