Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A7E16200BB4 for ; Tue, 1 Nov 2016 11:45:45 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A68B2160AF7; Tue, 1 Nov 2016 10:45:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id ED619160AE5 for ; Tue, 1 Nov 2016 11:45:44 +0100 (CET) Received: (qmail 65453 invoked by uid 500); 1 Nov 2016 10:45:44 -0000 Mailing-List: contact dev-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list dev@struts.apache.org Received: (qmail 65442 invoked by uid 99); 1 Nov 2016 10:45:44 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2016 10:45:44 +0000 Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id A38661A00D6 for ; Tue, 1 Nov 2016 10:45:43 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id n67so278287657wme.1 for ; Tue, 01 Nov 2016 03:45:43 -0700 (PDT) X-Gm-Message-State: ABUngvc45YZ0W0Ixuzjd7nSfaVK+8nl2Gtzm5j42ZeGzaMD0kE+c5FBUtQC2TT/f3elpORy+KVjLpdH95WuIMw== X-Received: by 10.28.145.134 with SMTP id t128mr961396wmd.50.1477997142088; Tue, 01 Nov 2016 03:45:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.29.75 with HTTP; Tue, 1 Nov 2016 03:45:21 -0700 (PDT) In-Reply-To: References: <6daff0c3-aac2-2d3a-72a8-1e84df455d6c@apache.org> From: Lukasz Lenart Date: Tue, 1 Nov 2016 11:45:21 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: long to s:date To: Struts Developers List Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable archived-at: Tue, 01 Nov 2016 10:45:45 -0000 2016-10-31 21:21 GMT+01:00 Lukasz Lenart : > 2016-10-29 21:50 GMT+02:00 Aleksandr Mashchenko : >> Instant is since 1.8, S2 is currently on 1.7. > > It'd be cool to give users option to define their own date provider or > something, anyway +1 to your idea :) This should be doable, the below code must be moved into an injectable bean which then can be used by Date component to convert any object into java.util.Date. Aleksandr can you push your code? Louis Can you register an issue in JIRA? try { //support Calendar also Object dateObject =3D findValue(name); if (dateObject instanceof java.util.Date) { date =3D (java.util.Date) dateObject; } else if(dateObject instanceof Calendar){ date =3D ((Calendar) dateObject).getTime(); } else { if (devMode) { String developerNotification =3D LocalizedTextUtil.find= Text( Date.class, "devmode.notification", ActionContext.getContext().getLocale(), "Developer Notification:\n{0}", new Object[]{ "Expression [" + name + "] passed to tag which was evaluated to [" + dateObject + "](" + (dateObject !=3D null ? dateObject.getClass() : "null") + ") isn't instance of java.util.Date nor java.util.Calendar!" } ); LOG.warn(developerNotification); } else { LOG.debug("Expression [{}] passed to tag which was evaluated to [{}]({}) isn't instance of java.util.Date nor java.util.Calendar!", name, dateObject, (dateObject !=3D null ? dateObject.getClass() : "null")); } } } catch (Exception e) { LOG.error("Could not convert object with key '{}' to a java.util.Date instance", name); } Regards --=20 =C5=81ukasz + 48 606 323 122 http://www.lenart.org.pl/ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org For additional commands, e-mail: dev-help@struts.apache.org