java - JSTL formatDate shows year + 1 in JSP -


i have problem. using in jsp following:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>  <fmt:formatdate type="date" pattern="dd.mm.yyyy" value="${booking.startdate}"/> 

having date : 2014-12-29 or represented long 1419807600000, displayed 29.12.2015, wrong.

what have found: formatdate uses internally gregoriancalendar#getweekyear() right after following piece of code :

if (field == calendarbuilder.week_year) {         if (calendar.isweekdatesupported()) {             value = calendar.getweekyear();         }... 

which goes piece of code inside gregoriancalendar#getweekyear() :

        if (year > gregoriancutoveryear + 1) {         int weekofyear = internalget(week_of_year);         if (internalget(month) == january) {             if (weekofyear >= 52) {                 --year;             }         } else {             if (weekofyear == 1) {                 ++year;             }         }         return year;     } 

obviosly, problem here :

if (weekofyear == 1) {       ++year; } 

so, week of year 1, because 29.12.2014 in first week of year 2015. use german locale this, means first week of year first week 4 or more days in new year.

still, format doesn't work properly. suggestions?

thanks lot.

yyyy week year, not year. yyyy year. see http://docs.oracle.com/javase/7/docs/api/java/text/simpledateformat.html


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -