public boolean checkChallanValidity(final Challan challan){
  final Calendar current=Calendar.getInstance();
  current.clear(Calendar.HOUR_OF_DAY);
  current.clear(Calendar.MINUTE);
  current.clear(Calendar.SECOND);
  current.clear(Calendar.MILLISECOND);
  final Calendar validityStart=Calendar.getInstance();
  validityStart.setTime(challan.getChallanDate());
  validityStart.clear(Calendar.HOUR_OF_DAY);
  validityStart.clear(Calendar.MINUTE);
  validityStart.clear(Calendar.SECOND);
  validityStart.clear(Calendar.MILLISECOND);
  final Calendar validityEnd=Calendar.getInstance();
  validityEnd.setTime(challan.getValidUpto());
  validityEnd.clear(Calendar.HOUR_OF_DAY);
  validityEnd.clear(Calendar.MINUTE);
  validityEnd.clear(Calendar.SECOND);
  validityEnd.clear(Calendar.MILLISECOND);
  if (validityStart.compareTo(current) <= 0 && validityEnd.compareTo(current) >= 0)   return true;
  return false;
}

public boolean checkChallanValidity ( final Challan challan ) { final Calendar current = Calendar . getInstance ( ) ; current . clear ( Calendar . HOUR_OF_DAY ) ; current . clear ( Calendar . MINUTE ) ; current . clear ( Calendar . SECOND ) ; current . clear ( Calendar . MILLISECOND ) ; final Calendar validityStart = Calendar . getInstance ( ) ; validityStart . setTime ( challan . getChallanDate ( ) ) ; validityStart . clear ( Calendar . HOUR_OF_DAY ) ; validityStart . clear ( Calendar . MINUTE ) ; validityStart . clear ( Calendar . SECOND ) ; validityStart . clear ( Calendar . MILLISECOND ) ; final Calendar validityEnd = Calendar . getInstance ( ) ; validityEnd . setTime ( challan . getValidUpto ( ) ) ; validityEnd . clear ( Calendar . HOUR_OF_DAY ) ; validityEnd . clear ( Calendar . MINUTE ) ; validityEnd . clear ( Calendar . SECOND ) ; validityEnd . clear ( Calendar . MILLISECOND ) ; if ( validityStart . compareTo ( current ) <= 0 && validityEnd . compareTo ( current ) >= 0 ) return true ; return false ; }
this method checks if the given challan is valid .
