Skip to content
Advertisement

How to get object from list with maximum date time object

Below is my code to find the contact object with the latest begin dateTime. DateTime is shown as an object.

Is there any method to simplify this code using streams and comparators.

JavaScript

Advertisement

Answer

I’m assuming that begin is a java.util.Date or any other Comparable? Then you could do:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement