http://blog.sina.com.cn/s/blog_617f5d090101ut63.htmlhtml
(2014-05-16 16:44:34)分類: 工做 |
解決了兩個問題ui
一、this
String強制轉換爲Datespa
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd"); String dateStr = request.getParameter("upmdateaa"); Date date =null; if(dateStr != null && !dateStr.equals("")){ try { date = format.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); }日誌
其中orm
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");htm
若是格式不對 則date就會爲空blog
例如:SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh-mm-ss");若是輸入的dateStr爲「2014-05-15」則date就會爲空ci
二、freemarker標籤裏date數據的顯示問題get
${(ads.upAdsDate)?if_exists}會出現顯示錯誤
錯誤日誌:
Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string. or ?string(format) built-in with this date. The problematic instruction:
更改成如下代碼則正常
${ads.upAdsDate?string('yyyy-MM-dd HH:mm:ss')}