Now, I just enhance the Java application and control the application form. The function will avoid the user to enter the wrong date. The condition as follow:
Expected result:
Start Date End Date
01-APR-2018 03-APR-2018
04-APR-2018 07-APR-2018
Show the error message: The secord record start date cannot greater than first record end date.
I try to compile the program but no any errors. Then, the function is not work.
public boolean CheckDateRecord(ExceptionGenerator eg, int dateCount, Date date, Date pstartdate, Date penddate, int id) throws Exception {
boolean CheckDate = false;
for (int i=1;i<=dateCount;i++)
{
Date date = hd.getdate( i );
Date startdate = date.getData(1); // Get Start Date
Date enddate = date.getData(2); // Get End Date
if (id != i &&
//check the record end date cannot greater than start date condition
((startdate.getValue().compareTo(pstartdate.getValue()) > 0 &&
pstartdate.getValue().compareTo(penddate.getValue()) > 0
) ))
{
CheckDate = true;
break;
}
}
return CheckDate;
}