code: public static <T extends Number> T parseNumber(String text, Class<T> targetClass, NumberFormat numberFormat) {
  		if (numberFormat != null) {
  			Assert.notNull(text, "Text must not be null");
  			Assert.notNull(targetClass, "Target class must not be null");
  			DecimalFormat decimalFormat = null;
  			boolean resetBigDecimal = false;
  			if (numberFormat instanceof DecimalFormat) {
  				decimalFormat = (DecimalFormat) numberFormat;
  				if (BigDecimal.class.equals(targetClass) && !decimalFormat.isParseBigDecimal()) {
  					decimalFormat.setParseBigDecimal(true);
  					resetBigDecimal = true;
  				}
  			}
  			try {
  				Number number = numberFormat.parse(StringUtils.trimAllWhitespace(text));
  				return convertNumberToTargetClass(number, targetClass);
  			}
  			catch (ParseException ex) {
  				throw new IllegalArgumentException("Could not parse number: " + ex.getMessage());
  			}
  			finally {
  				if (resetBigDecimal) {
  					decimalFormat.setParseBigDecimal(false);
  				}
  			}
  		}
  		else {
  			return parseNumber(text, targetClass);
  		}
  	}
docs: Parse the given text into a number instance of the given target class,
  using the given NumberFormat. Trims the input {@code String}
  before attempting to parse the number.
  @param text the text to convert
  @param targetClass the target class to parse into
  @param numberFormat the NumberFormat to use for parsing (if {@code null},
  this method falls back to {@code parseNumber(String, Class)})
  @return the parsed number
  @throws IllegalArgumentException if the target class is not supported
  (i.e. not a standard Number subclass as included in the JDK)
  @see java.text.NumberFormat#parse
  @see #convertNumberToTargetClass
  @see #parseNumber(String, Class)