Here Java need to read a file which has Contract, Member, Start-Date and End-Date. If there are date split/break in dates it need to be populated in a target file at contract level. Below provided the Source file and Target file example and the expected result.
In the example, Contract A has the split in Member 3, so in Target file the remaining date range need to populated at contract level
Contract B has the split in Member 3 and 4, so in Target file the missing date range and remaining date range need to populated at contract level.
Source File:
Contract Member StartDate EndDate
A 1 01-Jan-2020 31-Dec-2020
A 2 01-Jan-2020 31-Dec-2020
A 3 01-Jan-2020 24-Oct-2020
A 4 01-Jan-2020 31-Dec-2020
B 1 01-Jan-2020 31-Dec-2020
B 2 01-Jan-2020 31-Dec-2020
B 3 01-Jan-2020 04-Mar-2020
B 3 01-Apr-2020 31-Dec-2020
B 4 01-Jan-2020 04-Mar-2020
B 4 01-Apr-2020 31-Dec-2020
Target File:
Contract StartDate EndDate
A 01-Jan-2020 24-Oct-2020
A 25-Oct-2020 31-Dec-2020
B 01-Jan-2020 04-Mar-2020
B 05-Mar-2020 31-Mar-2020
B 01-Apr-2020 31-Dec-2020