/**
* 类型转换 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
可自定义输入的字符串日期格式.