struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: long to s:date
Date Tue, 01 Nov 2016 10:45:21 GMT
2016-10-31 21:21 GMT+01:00 Lukasz Lenart <lukaszlenart@apache.org>:
> 2016-10-29 21:50 GMT+02:00 Aleksandr Mashchenko <amashchenko@apache.org>:
>> 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 = findValue(name);
            if (dateObject instanceof java.util.Date) {
                date = (java.util.Date) dateObject;
            } else if(dateObject instanceof Calendar){
                date = ((Calendar) dateObject).getTime();
            } else {
                if (devMode) {
                    String developerNotification = LocalizedTextUtil.findText(
                            Date.class,
                            "devmode.notification",
                            ActionContext.getContext().getLocale(),
                            "Developer Notification:\n{0}",
                            new Object[]{
                                    "Expression [" + name + "] passed
to <s:date/> tag which was evaluated to [" + dateObject + "]("
                                            + (dateObject != null ?
dateObject.getClass() : "null") + ") isn't instance of java.util.Date
nor java.util.Calendar!"
                            }
                    );
                    LOG.warn(developerNotification);
                } else {
                    LOG.debug("Expression [{}] passed to <s:date/> tag
which was evaluated to [{}]({}) isn't instance of java.util.Date nor
java.util.Calendar!",
                            name, dateObject, (dateObject != null ?
dateObject.getClass() : "null"));
                }
            }
        } catch (Exception e) {
            LOG.error("Could not convert object with key '{}' to a
java.util.Date instance", name);
        }


Regards
-- 
Ɓukasz
+ 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


Mime
View raw message