The min non-null LocalDateTime of a list using stream

Viewed 1771

I know how to get the min LocalDateTime of a list thanks to: https://stackoverflow.com/a/20996009/270143

e.g. LocalDateTime minLdt = list.stream().map(u -> u.getMyLocalDateTime()).min(LocalDateTime::compareTo).get();

My problem is slightly different though...

  1. I would like the min LocalDateTime that is not null
  2. or null if they are all null

How would I go about doing that in a concise way?

2 Answers
Related