I have collection of object as Collection basics = periodic.getGeneratedBasic();
When iterate over this collection and get every object and cast it, i can extract date of every object.
Now at this point i want to check out in this collection of object which one is the smallness and biggest date.
Does any one know how to do that?
Date max;
Date min;
for(Object o:basics){
Basic b = (Basic) o;
Date temp;
if(b.State=='U'){
basicAList.add(ba);
dateCollection.add(b.firstDateTime);
temp= ;
if(b.firstDateTime <)
}
}
“How to get min and max date in Python” Code Answer's minimum=min(L1)#min() function helps to note smallest of the element. maximum=max(L1)#max() function helps to note biggest of the element.
Returns the maximum of the given dates. Use the ES6 spread syntax with Math. max() to find the maximum date value.
In Java 8 you can do:
final Date maxDate = dates.stream()
.max(Date::compareTo)
.get();
Date max = new Date(0);
Date min = new Date(0);
for(Object o:basics){
Basic b = (Basic) o;
if(b.State=='U'){
basicAList.add(ba);
dateCollection.add(b.firstDateTime);
if(min.compareTo(b.firstDateTime) > 0) min = b.firstDateTime;
else if(max.compareTo(b.firstDateTime) < 0) max = b.firstDateTime;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With