I need to return the boolean value based on the below condition. the calculate the date between from date , current date , to date and return the date basd on condition
fromdate(1st) -------currentdate(2nd)---------todate(3rd)
fromdate= before date/null
currentdate= system date
todate= afterdate/null
1 fromdate and todate is not null and current date is between fromdate and todate ,then it returns true
2.fromdate not null and fromdate <= currentdate and todate is null ,then it returns true
3.fromdate null and currentdate <= todate and todate is not null, it returns true
4.fromdate =null and todate =null , it returns false
the code i had written
************************************************** ***********************************
if (fromdate!=null && todate!=null && fromdate.compareTo(currentDate)<0 && todate.compareTo(currentDate)>0)
{return true;}
if else(fromdate!=null && fromdate.compareTo(currentDate)<0 && todate=null){return true;}
if else(todate !=null && todate.compareTo(currentDate)>0 && fromdate=null){return true;}
ifelse (fromdate==null && todate ==null) {return false;}
else{return false;}
************************************************** **********************************
It throws the null pointer exception, please help me out .