-
Notifications
You must be signed in to change notification settings - Fork 22
Description
In the Table , the calendar value is showing correctly in dd/MM/yyyy format, but when you click on 'sort ascending' or 'sort descending' , i guess its sorting based on formatted string in dd/MM/yyyy and not based on the actual date value.
The pojo is same as the one given in the test folders
*) public class Person {
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
.
.
@resolvable(formatter = DateFormatter.class)
private GregorianCalendar birth;
//constructor used
public Person(String name, int age, boolean live, String birth) {
this.name = name;
this.age = age;
this.live = live;
this.birth = new GregorianCalendar();
try {
this.birth.setTime(sdf.parse(birth));
} catch (ParseException e) {
e.printStackTrace();
}
}
}
*)DateFormatter.java
public class DateFormatter implements Formatter {
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
@OverRide
public String format(Object arg0) {
return format.format(((GregorianCalendar) arg0).getTime());
}
@OverRide
public String getName() {
return "calendar";
}
@OverRide
public Object parse(Object arg0) {
GregorianCalendar cal = new GregorianCalendar();
try {
cal.setTime(format.parse(arg0.toString()));
} catch (ParseException e) {
e.printStackTrace();
}
return cal;
}
}
*) TableFilterTest.java
here is the code
ObjectTableModel model = new ObjectTableModel(
new AnnotationResolver(Person.class), "name:Name,age:Age,live:Alive,birth:DOB");
model.setEditableDefault(false);
JTable table = new JTable(model);
new TableFilter(table);
model.addAll(PreData.getSampleList());
*)PreData.java
public class PreData {
public static List getSampleList() {
List list2 = new ArrayList();
list2.add(new Person("A", 10,true,"01/04/2014"));
list2.add(new Person("B", 20,true,"01/05/2014"));
list2.add(new Person("C", 30,true,"23/07/2014"));
list2.add(new Person("D", 40,false,"14/02/2014"));
list2.add(new Person("E", 50,false,"10/09/2014"));
return list2;
}