我有一个带@Service注释的服务类方法createShiftPlan(int numberOfEmployees, int startingMonth, int year),在其中我使用了SimpleDateFormat类的parse()方法。
我如何在这里测试整数输入的解析异常?
发布于 2020-02-03 21:18:12
将SimpleDateFormat.setLenient(false)设置为disable lenient parsing并提供一个不存在的日期,例如4月35日。如果lenient被禁用,这将抛出一个ParseException,而不是静默地修复日期。
https://stackoverflow.com/questions/60039992
复制相似问题