I know how to get min LocalDateTimefrom a list thanks to: https://stackoverflow.com/a/3166/
LocalDateTime
eg. LocalDateTime minLdt = list.stream().map(u -> u.getMyLocalDateTime()).min(LocalDateTime::compareTo).get();
LocalDateTime minLdt = list.stream().map(u -> u.getMyLocalDateTime()).min(LocalDateTime::compareTo).get();
My problem is a little different though ...
null
How will I do this in a concise manner?
You can simply do:
Optional<LocalDateTime> op = list.stream() .filter(Objects::nonNull) .min(Comparator.naturalOrder());
And the value absentindicates that there are only zeros in your list (or your list is empty)
absent
Something like this, maybe?
LocalDateTime minDate = list.stream() .filter(Objects::nonNull) .map(u -> u.date) .min(LocalDateTime::compareTo) .orElse(null);
Source: https://habr.com/ru/post/1685577/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1685572/how-to-convert-partial-functions-to-safemaybe-functions&usg=ALkJrhgNkDCIqoOvOnqX82iP6D0C23L9jAHow to use multilayer bidirectional LSTM in Tensorflow? - tensorflowhow to use if condition in ionic popup - angularjsHow to create a custom component in Angular Material 2 - angularReform Dataframe in pandas - pythonНажмите ссылку на строковый элемент в массиве в новый массив строки - performanceThe number of conditions on the keys is invalid: damo dyna with node js - node.jsGetting "This action will increase the number of cells per sheet over the limit of 2,000,000 cells" when calling the sheet API - google-spreadsheet-apiMongo convert document to DBObject - javaExcel macro not VBA - vbaAll Articles