jsf 2 glassfish 4 primefaces 5.1
我正在使用f:convertDateTime转换显示日期的方式,但显示的日期错误。
当我正常显示日期时
星期六2011年1月1日00:00:00 AST
这是正确的,但不是我想要显示的
所以我用的是<f:convertDateTime dateStyle="short"></f:convertDateTime>
但没有显示
2011年1月1日
它给了我
10/12/31
我尝试使用<f:convertDateTime pattern="MM/dd/yyyy"></f:convertDateTime>
,但这也给了我
2010年12月31日
代替
2011年1月1日
<p:column headerText="Installation Date"
filterBy="#{w.installationDate}"
filterMatchMode="contains"
sortBy="#{w.installationDate}">
<h:outputText value="#{w.installationDate}" >
<f:convertDateTime pattern="MM/dd/yyyy"></f:convertDateTime>
</h:outputText>
</p:column>
最佳答案
尝试将其添加到您的web.xml
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>