Good idea - that worked - thanks!

Matt

> -----Original Message-----
> From: Jerome Jacobsen [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 30, 2003 10:00 AM
> To: Struts Users Mailing List
> Subject: RE: [OT] Display Tag Library - Sorting Dates
> 
> 
> Couldn't you subclass Date and override toString?
> 
> > -----Original Message-----
> > From: Raible, Matt [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 30, 2003 11:41 AM
> > To: '[EMAIL PROTECTED]'
> > Cc: '[EMAIL PROTECTED]'
> > Subject: [OT] Display Tag Library - Sorting Dates
> >
> >
> > 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to