Changing the DatePattern in DataTable

View: New views
2 Messages — Rating Filter:   Alert me  

Changing the DatePattern in DataTable

by nanotech :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

How can I change the pattern for a column displaying date from database in DataTable.
In my case it displays the Short date format by default. which is mm/dd/yy
I want to able to display MM/dd/yyyy.

Thanks,
RG

Re: Changing the DatePattern in DataTable

by Mr Mean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Extend one of the defaultcolumns, like propertycolumn, and override
onpopulateitem.
Something like this:
public void populateItem(Item item, String componentId, IModel model)
        {
                item.add(new Label(componentId, createLabelModel(model))
                {
                        private static final long serialVersionUID = 1L;

                        @Override
                        @SuppressWarnings( {"unused", "unchecked"})
                        public IConverter getConverter(Class type)
                        {
                                return Application.get().getConverterLocator().getConverter(Time.class);
                        }
                }.setRenderBodyOnly(true));
        }

Or if you are using a propertycolumn you could override
createLabelModel to return a custom model that handles the formatting
for you.

Maurice

On Wed, Jul 16, 2008 at 6:51 AM, nanotech <rachit.gandhi@...> wrote:

>
> Hi,
>
> How can I change the pattern for a column displaying date from database in
> DataTable.
> In my case it displays the Short date format by default. which is mm/dd/yy
> I want to able to display MM/dd/yyyy.
>
> Thanks,
> RG
> --
> View this message in context: http://www.nabble.com/Changing-the-DatePattern-in-DataTable-tp18480202p18480202.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

LightInTheBox - Buy quality products at wholesale price