public void setDateOfSale(Date dateOfSale) {
Calendar today = Calendar.getInstance();
//Date of sale cannot be null
if(dateOfSale == null)
throw new BusinessRuleException("Date of sale cannot be null");
else{
Calendar saleCal = Calendar.getInstance();
saleCal.setTime(dateOfSale);
if(saleCal.get(Calendar.YEAR) != today.get(Calendar.YEAR))
throw new BusinessRuleException("The Year in Date of Sale must be the current year");
if(saleCal.get(Calendar.MONTH)!= today.get(Calendar.MONTH))
throw new BusinessRuleException("The Month in Date of Sale must be the current month");
if(saleCal.get(Calendar.DAY_OF_YEAR)!= today.get(Calendar.DAY_OF_YEAR))
throw new BusinessRuleException("The Day in Date of Sale must be todays date.");
}
this.dateOfSale = dateOfSale;
}