Freemarker中日期時間格式出錯

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

先貼出錯誤信息。服務器

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"ui

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

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

  因而我在頁面頭部作了一個setting問題就解決了。orm

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

  可是疑問在於,明明是服務器端的代碼(freemarker),爲什麼會和客戶端的環境相關呢。htm

相關文章
相關標籤/搜索