struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raible, Matt" <Matt_Rai...@cable.comcast.com>
Subject [OT] Display Tag Library - Sorting Dates
Date Thu, 30 Jan 2003 16:40:57 GMT
Since there seems to be a lot of <display:*> users on this list, I thought
I'd ask this question here - hope you don't mind.

I have a string in my form that is a date.  In order to get the display tag
library to sort this column (date) correctly, I have added the following
method in a Decorator:

    public Date getDate() {
        MyForm form = (MyForm) this.getObject();
	  Date d = null;
        try {
            d = DateUtil.convertStringToDate(DateUtil.getUIDatePattern(),
form.getDate);
        } catch (ParseException pe) {
            pe.printStackTrace();
            log.error("Error converting String date to real Date: " + pe);
        }
        return d;
    }

The problem is that the display tag just calls toString() on the date, so I
end up with the following in my column:

Thu Feb 06 00:00:00 MST 2003

When I want, something like Feb 6, 2003.  However, to do this, I need to
return a String, and then it doesn't sort correctly.  I can hack the code in
the display tag library to try to parse all columns, and if it succeeds then
it assumes it is a date, and uses a format.  But I'm hoping that someone has
a more elegant solution.

Thanks,

Matt


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message