Freemarker中日期時間格式出錯


今天遇到一個奇怪的問題。同事訪問我電腦發布的程序頁面,freemarker日期格式報錯。而其他電腦訪問則沒有問題。

先貼出錯誤信息。

FreeMarker template error

The string doesn't match the expected date/time/date-time format. The string to parse was: "2015-08-27 11:50:35.013". The expected format was: "MMM d, yyyy h:mm:ss a".
The nested reason given follows:
Unparseable date: "2015-08-27 11:50:35.013"

----
FTL stack trace ("~" means nesting-related):
    - Failed at: ${model.jzUser.scdlsj?datetime}  [in template "right.htm" at line 80, column 49]
----

Java stack trace (for programmers):
----
freemarker.core._TemplateModelException: [... Exception message was already printed; see it above ...]

  也就是說,默認的日期格式在同事的電腦變成了:"MMM d, yyyy h:mm:ss a"

  在官網查看了一些資料,其中提到了默認日期的格式的問題。

  http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_string_date

  於是我在頁面頭部做了一個setting問題就解決了。

<#setting datetime_format="yyyy-MM-dd HH:mm:ss"/>

  但是疑問在於,明明是服務器端的代碼(freemarker),為何會和客戶端的環境相關呢。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM