final SimpleQuote volatilityQuote = new SimpleQuote(0.3);
final RelinkableHandle<Quote> handleToVolatilityQuote = new RelinkableHandle<Quote>(volatilityQuote);
BlackVolatilityTermStructure constantVolatility = new BlackConstantVol(2,new UnitedStates(Market.NYSE),handleToVolatilityQuote, new Actual365Fixed());
//Calculating blackVolatility using maturity as 10 days after today and strike as 20
Double volatility1 = constantVolatility.blackVol(date10.clone(), 20);
System.out.println("BlackVolatility = "+volatility1);
//Calculating blackVolatility using maturity as 20 days after today and strike as 30
Double volatility2 = constantVolatility.blackVol(date20.clone(), 30);
System.out.println("BlackVolatility = "+volatility2);