code: public static HazardCurve createHazardCurveFromHazardRate(String name, double[] times, double[] givenHazardRates){
  
  		double[] givenSurvivalProbabilities = new double[givenHazardRates.length];
  
  		if(givenHazardRates[0]<0) {
  			throw new IllegalArgumentException("First hazard rate is not positive");
  		}
  
  		//initialize the term structure
  		givenSurvivalProbabilities[0] = Math.exp(- givenHazardRates[0] * times[0]);
  
  		/*
  		 * Construct the hazard curve by numerically integrating the hazard rates.
  		 * At each step check if the input hazard rate is positive.
  		 */
  		for(int timeIndex=1; timeIndex<times.length;timeIndex++) {
  
  			if(givenHazardRates[timeIndex]<0) {
  				throw new IllegalArgumentException("The " + timeIndex + "-th hazard rate is not positive");
  			}
  
  			givenSurvivalProbabilities[timeIndex] = givenSurvivalProbabilities[timeIndex-1] * Math.exp(- givenHazardRates[timeIndex] * (times[timeIndex]-times[timeIndex-1]));
  		}
  
  		return createHazardCurveFromSurvivalProbabilities(name, times, givenSurvivalProbabilities);
  	}
docs: Create a discount curve from given times and given zero rates using default interpolation and extrapolation methods.
  The discount factor is determined by
  <code>
  givenSurvivalProbabilities[timeIndex] = givenSurvivalProbabilities[timeIndex-1] * Math.exp(- givenHazardRates[timeIndex] * (times[timeIndex]-times[timeIndex-1]));
  </code>
  
  @param name The name of this discount curve.
  @param times Array of times as doubles.
  @param givenHazardRates Array of corresponding zero rates.
  @return A new discount factor object.