thankyou for your response.
This worked. But have a question. I am using sorting for this column too.
I made sure this column data is of type Date for sorting to work right.
Does this get sorted right I mean the Dates if the column data is String
type no right!!
From: "Rick Herrick" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: [displaytag-user] Column Decorator for Date
Date: Thu, 10 Nov 2005 08:09:55 -0800 (PST)
fea jabi said:
> I am having a column which is displaying Dates in the below format.
>
> Mon Oct 10 00:00:00 EDT 2005
>
>
> But want the format to be in MM/dd/yy format.
>
> How can this be done?
>
> Thanks.
Create a class that extends ColumnDecorator and implements the decorate()
method. I included an example at the bottom of my reply. Then just apply
that to the column you want to format:
<display:column property="myDate" decorator="ShortDateDecorator" />
Here's the class:
public class ShortDateDecorator implements ColumnDecorator
{
/**
* Used to format the date object.
*/
SimpleDateFormat dateFormat = new SimpleDateFormat("M/d/yyyy");
/**
* transform the given object into a String representation.
* @param columnValue Object
* @return String
*/
public final String decorate(Object columnValue)
{
String formattedDate = null;
if (columnValue instanceof Date)
{
formattedDate = dateFormat.format((Date) columnValue);
}
else if (columnValue instanceof String)
{
try
{
formattedDate =
dateFormat.format(dateFormat.parse((String)
columnValue));
}
catch (ParseException e)
{
//
}
}
return formattedDate;
}
}
--
Rick Herrick
[EMAIL PROTECTED]
I haven't got time for inner peace.
Get out of control, but appear under control. It's not bad to alarm other
people, though--it's good for them.--Hunter S. Thompson
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user