I want to find a matching or a closest entry from a collection for a given timestamp value.
My collection is List of Object.. which contains name, id, timestamp etc..
String id;
long timestamp;
I want to first match on Id(you can have multiple) and then find the match for a given timestamp or return closest to it from collection. how can i do that?
myList.stream().filter(p -> p.getId().equals(Id))
.min((f1,f2) -> Math.abs(f1.getTS() - timestamp) - Math.abs(f2.getTS() - timestamp))
.findfirst().get();
its also having issue with long to int conversion too.
error : type mismatch - cannot convert from long to int.