Date oDate= Entitlement_End_Date__c; //Date class from java.util
Double factor=0;
if(oDate.daysBetween(date.today())>0){
//i.e if days between oDate and today is positive, means that oDate happened before //today's day thus meaning product is expried.
factor=((oDate.daysBetween(date.today())/365.00));
if(factor>1) //greater than one year
factor=1; // set the factor as one
factor+=(date.today().daysBetween(TheEndDate)/365.00); //if factor is greater than //one, we want to find the exact amount of time it has expired for.
}
else{
factor=oDate.daysBetween(TheEndDate)/365.00;
I'm sure that there's an easier/simpler way of writing this that will require less lines of code? I just can't see it. Does anyone else know how to compress this into cleaner code?