Have a Map as HashMap<ItemNo, List<Price>>
in my application. Each itemNo having many price intervals.
Each price interval is having FROM_DTIME, TO_DTIME.
Need to find the all price objects whose are having overlapping interval by writing java logic.
Example overlapping interval is as below, 2nd interval should start after completion of 1st interval i.e 01-SEP-19. but it started at 08-AUG-19.
i tried as below ,
for (int i = 0; i < vGroupedByItemNoMap.get(itemNo).size(); i++) {
Price vCurrent = vGroupedByItemNoMap.get(itemNo).get(i);
Price vNext = (i == 0 ? null : vGroupedByItemNoMap.get(itemNo).get(i + 1));
DateTime vCurrentTodate = vCurrent.getToDate().plusSeconds(1);
if (vNext != null) {
DateTime vNextFromdate = vNext.getFromDate();
if (vCurrentTodate != vNextFromdate) {
vOverlappedItemNoList.addAll(vGroupedByItemNoMap.get(itemNo));
log.info(
"Prices having Overlapping and [ItemNos ={}] are not processed.",vOverlappedItemNoList);
break;
}
}
}
Can any one help me here how find such overlapping intervals.