I have two date fields in Temp class say validFromDate and asOfDate. I have List with me. I need to set the flag whihc is one of the class attributes to true for the record whose validFromDate is closest to asOfDate
Ex.
List<temp> {
Temp1:
asOfDate: 2018-01-04
validFrom: 2018-01-01
Temp2:
asOfDate: 2018-01-04
validFrom: 2018-01-02
Temp3:
asOfDate: 2018-01-04
validFrom: 2018-01-03
}
o/p should be Temp3 as this validFrom is nearest to asOfdate. I will set the flag to true for this Temp2
How can I achieve this using Java 8 streams?
Temp3
?