我试图根据日期查找数据引发异常
java.lang.IllegalArgumentException:空
@SuppressWarnings("deprecation")
@GetMapping("/product-DateList/{pathDate}")
public ModelAndView getFindByDateOfPurchase(@PathVariable("pathDate") String pathDate) {
Date convertDate = new Date(pathDate);
//Date Converted according to dataBase Format
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String strDate = sdf.format(convertDate);
Date date = null;
try {
date = DateFormat.getInstance().parse(strDate);
} catch (ParseException pe) {
pe.printStackTrace();
}
List<Product> dateofPurchaseList = grofersService.findByDateOfPurchase(date);
Optional<List<Product>> optional = Optional.of(dateofPurchaseList);
if (!optional.isPresent()) {
logger.warn("Not Found Product");
return new ModelAndView("notFound");
}
logger.info("Fetching Product according to Date");
return new ModelAndView("productList", "dateofPurchaseList", dateofPurchaseList);
}
在google中搜索此问题找不到此类问题,如何根据日期查找数据。
杨__羊羊
哈士奇WWW
相关分类