public boolean dateRange(Object day1,Object month1,Object year1,Object day2,Object month2,Object year2,Object gmt){
  Map<String,Integer> params=new HashMap<String,Integer>();
  parseDateParam(params,day1);
  parseDateParam(params,month1);
  parseDateParam(params,year1);
  parseDateParam(params,day2);
  parseDateParam(params,month2);
  parseDateParam(params,year2);
  parseDateParam(params,gmt);
  boolean useGmt=params.get("gmt") != null;
  Calendar cal=getCurrentTime(useGmt);
  Date current=cal.getTime();
  if (params.get("day1") != null) {
    cal.set(Calendar.DAY_OF_MONTH,params.get("day1"));
  }
  if (params.get("month1") != null) {
    cal.set(Calendar.MONTH,params.get("month1"));
  }
  if (params.get("year1") != null) {
    cal.set(Calendar.YEAR,params.get("year1"));
  }
  Date from=cal.getTime();
  Date to;
  if (params.get("day2") != null) {
    cal.set(Calendar.DAY_OF_MONTH,params.get("day2"));
  }
  if (params.get("month2") != null) {
    cal.set(Calendar.MONTH,params.get("month2"));
  }
  if (params.get("year2") != null) {
    cal.set(Calendar.YEAR,params.get("year2"));
  }
  to=cal.getTime();
  if (to.before(from)) {
    cal.add(Calendar.MONTH,+1);
    to=cal.getTime();
  }
  if (to.before(from)) {
    cal.add(Calendar.YEAR,+1);
    cal.add(Calendar.MONTH,-1);
    to=cal.getTime();
  }
  return current.compareTo(from) >= 0 && current.compareTo(to) <= 0;
}

public boolean dateRange ( Object day1 , Object month1 , Object year1 , Object day2 , Object month2 , Object year2 , Object gmt ) { Map < String , Integer > params = new HashMap < String , Integer > ( ) ; parseDateParam ( params , day1 ) ; parseDateParam ( params , month1 ) ; parseDateParam ( params , year1 ) ; parseDateParam ( params , day2 ) ; parseDateParam ( params , month2 ) ; parseDateParam ( params , year2 ) ; parseDateParam ( params , gmt ) ; boolean useGmt = params . get ( "gmt" ) != null ; Calendar cal = getCurrentTime ( useGmt ) ; Date current = cal . getTime ( ) ; if ( params . get ( "day1" ) != null ) { cal . set ( Calendar . DAY_OF_MONTH , params . get ( "day1" ) ) ; } if ( params . get ( "month1" ) != null ) { cal . set ( Calendar . MONTH , params . get ( "month1" ) ) ; } if ( params . get ( "year1" ) != null ) { cal . set ( Calendar . YEAR , params . get ( "year1" ) ) ; } Date from = cal . getTime ( ) ; Date to ; if ( params . get ( "day2" ) != null ) { cal . set ( Calendar . DAY_OF_MONTH , params . get ( "day2" ) ) ; } if ( params . get ( "month2" ) != null ) { cal . set ( Calendar . MONTH , params . get ( "month2" ) ) ; } if ( params . get ( "year2" ) != null ) { cal . set ( Calendar . YEAR , params . get ( "year2" ) ) ; } to = cal . getTime ( ) ; if ( to . before ( from ) ) { cal . add ( Calendar . MONTH , + 1 ) ; to = cal . getTime ( ) ; } if ( to . before ( from ) ) { cal . add ( Calendar . YEAR , + 1 ) ; cal . add ( Calendar . MONTH , - 1 ) ; to = cal . getTime ( ) ; } return current . compareTo ( from ) >= 0 && current . compareTo ( to ) <= 0 ; }
only the first parameter is mandatory . all other parameters can be left out therefore the meaning of the parameters changes . the method definition shows the version with the most possible parameters filled . the real meaning of the parameters is guessed from it ' s value . if " from " and " to " are specified then the bounds are inclusive . if the " gmt " parameter is specified , times are taken to be in gmt , otherwise the local time zone is used .
