[ https://issues.apache.org/jira/browse/FREEMARKER-91?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Dekany closed FREEMARKER-91. ----------------------------------- Resolution: Not A Bug That's because year is "y" (lower case). "Y" is Week Year. "Y" was added to Java {{SimpleDateFormat}} in Java 7. I can only praise the geniuses behind this, choosing "Y" for this, instead of any random letter. See, upper- VS lower-case is already quite inconsistent in those patterns, but now if you dare to write "Y" by mistake... no error message for you anymore. Instead, you get a hidden bug in your application that bites near the edge of years. And FreeMarker just exposes that patterns supported by Java. We should block "Y" somehow. > Converting Dec 31 2018 to a string prints Dec 31 2019 > ----------------------------------------------------- > > Key: FREEMARKER-91 > URL: https://issues.apache.org/jira/browse/FREEMARKER-91 > Project: Apache Freemarker > Issue Type: Bug > Reporter: Eran Belinsky > Priority: Minor > > I've encountered the following (verified on try.freemarker.org), after a > report from one of my users (we render the templates for them): > Template: > ${timestamp_ms_2018_12_31_12?number?number_to_date} > ${timestamp_ms_2018_12_31_12?number?number_to_date?string("MMMM dd, YYYY")} > ${timestamp_ms_2018_12_29_12?number?number_to_date?string("MMMM dd, YYYY")} > Data model: > timestamp_ms_2018_12_31_12 = "1546243200000" > timestamp_ms_2018_12_29_12 = "1546070400000" > Result: > Dec 31, 2018 > December 31, 2019 > December 29, 2018 > I know that java.util.Date is bad due to no timezone support, but how does > the string conversion get it wrong by a whole year? > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)