public Double getUnitsBefore(Date recordDate) {
double eligibleUnits = 0;
ageBucket.forEach((dateStr, units) -> {
try {
Date date = DFT.parse(dateStr);
if (date.before(recordDate)) {
//TODO These are eligible units for dividend.
eligibleUnits = eligibleUnits + units.doubleValue(); //TODO
}
} catch(ParseException e) {
e.printStackTrace();
}
});
return eligibleUnits;
}
- As you know line
eligibleUnits = eligibleUnits + units.doubleValue();
does not compile in Java 8. How do i achieve this? I need to sum only when date is before record date.