Commit d8dc9e35 by zhangxingmin

push

parent f9ee0fb4
......@@ -229,16 +229,26 @@ public class ApiCsfCommonServiceImpl implements ApiCsfCommonService {
LocalDate currentDate = LocalDate.now();
if (birthDate.isAfter(currentDate)) {
throw new IllegalArgumentException("生日日期不能于当前日期");
throw new IllegalArgumentException("生日日期不能于当前日期");
}
Period period = Period.between(birthDate, currentDate);
return String.valueOf(period.getYears());
} catch (Exception e) {
throw new IllegalArgumentException("生日格式不正确,应为yyyy-MM-dd格式");
// throw new IllegalArgumentException("生日格式不正确,应为yyyy-MM-dd格式");
throw new IllegalArgumentException(e.getMessage());
}
}
public static void main(String[] args) {
ApiCsfCommonServiceImpl commonService = new ApiCsfCommonServiceImpl();
ApiCsfCalculateRequest request = new ApiCsfCalculateRequest();
request.setRequestValue("310111202603191111");
request.setCalculateType(6);
Result<List<ApiCsfCalculateResponse>> result = commonService.calculate(request);
System.out.println(result);
}
/**
* 身高和体重计算BMI指数
* @param requestValueList
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment