Java 8 lambda comparator with null value check [duplicate]
There are default implementations within Comparator you can use: nullsFirst
or nullsLast
:
Comparator.comparing(YourObject::getStartDate,
Comparator.nullsFirst(Comparator.naturalOrder())
)