From notifications-return-5073-archive-asf-public=cust-asf.ponee.io@freemarker.incubator.apache.org Mon Mar 5 17:23:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 0D113180677 for ; Mon, 5 Mar 2018 17:23:03 +0100 (CET) Received: (qmail 52380 invoked by uid 500); 5 Mar 2018 16:23:03 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 52371 invoked by uid 99); 5 Mar 2018 16:23:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2018 16:23:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 804341804E6 for ; Mon, 5 Mar 2018 16:23:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id WqTjGh80JtsH for ; Mon, 5 Mar 2018 16:23:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 5C52D5FBE5 for ; Mon, 5 Mar 2018 16:23:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 8FDEFE021F for ; Mon, 5 Mar 2018 16:23:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 4B88C21268 for ; Mon, 5 Mar 2018 16:23:00 +0000 (UTC) Date: Mon, 5 Mar 2018 16:23:00 +0000 (UTC) From: "Daniel Dekany (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Closed] (FREEMARKER-91) Converting Dec 31 2018 to a string prints Dec 31 2019 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FREEMARKER-91?page=3Dcom.atlas= sian.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= =C2=A0Java {{SimpleDateFormat}}=C2=A0in Java 7. I can only praise the geniu= ses behind this, choosing "Y" for this, instead of any random letter.=C2=A0= 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 any= more. Instead, you get=C2=A0a hidden bug in your application that bites nea= r 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 =3D "1546243200000" > timestamp_ms_2018_12_29_12 =3D "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 doe= s the string conversion get it wrong by a whole year? > =C2=A0 > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)