Coder Social home page Coder Social logo

Comments (8)

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

Hi @sanakalam,

can you pleas show your comparator for the date column?

Best regards,
Ingo

from sortabletableview.

sanakalam avatar sanakalam commented on July 18, 2024

tableView.setColumnComparator(6, new Comparator() {
@OverRide
public int compare(RequestInquiryModel o1, RequestInquiryModel o2) {
return o1.getCreatedOn().compareTo(o2.getCreatedOn());
}
});

from sortabletableview.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

What data type does getCreatedOn() return? String?

from sortabletableview.

sanakalam avatar sanakalam commented on July 18, 2024

yeah String. I am fetching data from API and date return as a String

from sortabletableview.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

I would suggest to transform the string to date using SimpleDateFormat.

from sortabletableview.

sanakalam avatar sanakalam commented on July 18, 2024

SimpleTableDataColumnAdapter c7 = new SimpleTableDataColumnAdapter<>((SimpleTableDataColumnAdapter.StringValueExtractor) data -> data.getCreatedOn().toString());

For Date which method we have to use instead of StringValueExtractor because it only accepts String value.

from sortabletableview.

ISchwarz23 avatar ISchwarz23 commented on July 18, 2024

Hi you can use SimpleDateFormat to turn you Date into a String.

SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); // TODO: adapt pattern

SimpleTableDataColumnAdapter c7 = new SimpleTableDataColumnAdapter<>(
    (SimpleTableDataColumnAdapter.StringValueExtractor) data -> dateFormatter.format(data.getCreatedOn()));

from sortabletableview.

sanakalam avatar sanakalam commented on July 18, 2024

@ISchwarz23 Thanks For your Support.
I use below code it works:
SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
tableView.setColumnComparator(6, new Comparator() {
@OverRide
public int compare(RequestInquiryModel o1, RequestInquiryModel o2) {
Date d1=null;
Date d2=null;
try {
d1=format.parse(o1.getCreatedOn());
d2=format.parse(o2.getCreatedOn());
} catch (ParseException e) {
e.printStackTrace();
}
return d1.compareTo(d2);
}

from sortabletableview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.