code: private List<Period> _Intersect( List<Period> periods1, List<Period> periods2 )
  	{
  		List<Period> result = new ArrayList<Period>();
  
  		int count1 = periods1.size();
  		int count2 = periods2.size();
  
  		int i = 0;
  		int j = 0;
  
  		while( i < count1 && j < count2 )
  		{
  			// one of the periods begins after the end of the other
  			if( periods1.get( i ).getFrom().compareTo( periods2.get( j ).getTo() ) > 0 )
  			{ // period 1 begins after period 2 finishes => period2 is
  				// eliminated !
  				j++;
  			}
  			else if( periods2.get( j ).getFrom().compareTo( periods1.get( i ).getTo() ) > 0 )
  			{ // period 2 begins after end of period 1 => period 1 is eliminated
  				// !
  				i++;
  			}
  
  			// after that test, we can assume there is a non-void intersection
  			else
  			{
  				// result[] = array( max($periods1[$i][0],$periods2[$j][0]),
  				// min($periods1[$i][1],$periods2[$j][1]) );
  				result.add( new Period( CalendarFunctions.max_date( periods1.get( i ).getFrom(), periods2.get( j ).getFrom() ), CalendarFunctions.min_date( periods1.get( i ).getTo(), periods2.get( j ).getTo() ) ) );
  
  				if( periods1.get( i ).getTo().compareTo( periods2.get( j ).getTo() ) > 0 )
  					j++;
  				else
  					i++;
  			}
  		}
  
  		return result;
  	}
docs: intersect two period arrays