struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raible, Matt" <>
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(),
        } catch (ParseException pe) {
            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.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message