code: public List<Period> _Merge( List<Period> pPeriods )
  	{
  		List<Period> result = new ArrayList<Period>();
  
  		int count = pPeriods.size();
  		if( count == 0 )
  			return result;
  
  		// copy the first period
  		result.add( pPeriods.get( 0 ) );
  
  		// init
  		int resIdx = 0;
  		int i = 1;
  
  		while( i < count )
  		{
  			if( pPeriods.get( i ).getFrom().compareTo( CalendarFunctions.date_add_day( result.get( resIdx ).getTo(), 1 ) ) > 0 )
  			{
  				// period is disjointed, so add it
  				result.add( pPeriods.get( i ) );
  				resIdx++;
  			}
  			else
  			{
  				// period is jointed so merge
  				result.get( resIdx ).setTo( CalendarFunctions.max_date( result.get( resIdx ).getTo(), pPeriods.get( i ).getTo() ) );
  			}
  			i++;
  		}
  
  		return result;
  	}
docs: merge, that is combine overlapping periods