How to Sort Java List Objects by Date property with Examples


In the tutorial, We discuss how to Sort Java List Objects by Date property with difference Date types: java.util.Date(using SimpleDateFormat), LocalDate, LocalDateTime. Java provides 2 main approaches for sorting Java List with Comparator:

  • java.util.Collections.sort(List list, Comparator< ? super Customer> c): sorting the specified list according to the order providing by the specified comparator.
  • java.util.Collection.stream().sorted(Comparator< ? super T> comparator): returning a stream consisting of the elements of this stream, sorted according to the provided Comparator.

Let’s do more details with Java syntax examples (Java 7 and Java 8) by descending and ascending sorting order.

[Continue reading…] “How to Sort Java List Objects by Date property with Examples”

Java 8 – How to convert List to Map & Map to List

In the tutorial, JavaSampleApproach will guide you How to convert List to Map (Map to List) with Java 8.

Related Posts:
1. Java 8 – Lambda Expressions
2. Java 8 – Functional Interfaces
3. Java 8 – Method References

[Continue reading…] “Java 8 – How to convert List to Map & Map to List”