Java: Order a list of Objects based on Calendar date?

Tags: , , ,

I have a list of Java Objects that all contain the following field:

@Column(name = "date")
private Calendar date;

I want to order the list of objects based on the above field , the object with date field most recent first.

What is the best way to do so?


You can use Comparator.comparing, suppose you have List<Entity> then you can do this way


Source: stackoverflow