You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Amol Yadwadkar <ay...@webifyservices.com> on 2003/08/21 12:13:22 UTC

Sorting on the Date Format Treating it as Date and not as String for the table Component

Hi All/MB,
I am using Table Component.I have the following Issue:-
I am having one Column which shall accept Date in the Format as "Aug 21, 2003 10:37am PST" and I will like to sort in this Format from Table Component.
Is it Possible ?

Problems that I am facing:-
1>> Date type object does not give me the facility to convert it into the Format as "Aug 21, 2003 10:37am PST" (same Date Object) it will be the String 
(I mean "Aug 21, 2003 10:37am PST " will be treatted as String) and Sorting will happen for the String and not for the Date which is required.

Please let me know if I am not clear with my Problem to u all
Thankx
best regds,
Amol

RE: Sorting on the Date Format Treating it as Date and not as String for the table Component

Posted by tsvetelin <ts...@rushmore-digital.com>.
Hi Amol,

If I understand you correctly you want to present date value in your custom
date format but you want it to be sorted as a date object. So here is my
solution:

Extend class SimpleTableColumn and override the following methods:

    /**
      * this method will return the string presentation of date in your data
format
      */
  public IRender getValueRenderer(IRequestCycle arg0, ITableModelSource
arg1, Object arg2);

    /**
      * This method will return the real date object - java.util.Date
      */
  public Object getColumnValue(Object arg0);

The default column comparator uses the second method to obtain a columnValue
for each row. That will be a Date object that implements Comparable
interface so they will be compared as a date objects(not as a string
presentation).


Tsvetelin.

-----Original Message-----
From: Amol Yadwadkar [mailto:ayadwadkar@webifyservices.com]
Sent: Thursday, August 21, 2003 1:13 PM
To: Tapestry users
Subject: Sorting on the Date Format Treating it as Date and not as
String for the table Component


Hi All/MB,
I am using Table Component.I have the following Issue:-
I am having one Column which shall accept Date in the Format as "Aug 21,
2003 10:37am PST" and I will like to sort in this Format from Table
Component.
Is it Possible ?

Problems that I am facing:-
1>> Date type object does not give me the facility to convert it into the
Format as "Aug 21, 2003 10:37am PST" (same Date Object) it will be the
String
(I mean "Aug 21, 2003 10:37am PST " will be treatted as String) and Sorting
will happen for the String and not for the Date which is required.

Please let me know if I am not clear with my Problem to u all
Thankx
best regds,
Amol