/** * 类型转换 String => Date * * @param time 字符串日期 * @return Date */ private static Date StringToDate(String time) { if (time == null) return null; SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); try { return sdf.parse(time); } catch (ParseException e) { //字符串格式不匹配,抛出异常->"参数错误" e.printStackTrace(); //throw new APIException(ResponseCode.PARAM_ERROR); 自定义异常 } }
通过修改
yyyyMMdd
可自定义输入的字符串日期格式.
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术