Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

f:convertDateTime displays wrong Year

Tags:

datetime

jsf

I am trying to display the date from my DB (which is mysql). And it shows all the dates correctly except one date. When displaying the last day of the year (31st December), the day and month values are correct but the year value shows the next year.

This is my code:

<h:outputText value="#{bean.date}" >
    <f:convertDateTime pattern="dd/MM/YYYY"/>
</h:outputText>

And in my web.xml file I have this code:

<context-param>
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    <param-value>true</param-value>
</context-param>

For 31/12/2013, it shows 31/12/2014 and this is the same for all years.

How can I solve this?

Thanks.

like image 253
Selcuk Avatar asked Dec 19 '13 15:12

Selcuk


1 Answers

As per the javadoc, the correct pattern for year is yyyy, not YYYY. With YYYY, the year in which the week falls would be used instead. 30 and 31 december 2013 participate in week 1 of year 2014.

like image 118
BalusC Avatar answered Oct 11 '22 05:10

BalusC