@SuppressWarnings("unchecked")
	private static <T extends Number> T parseNumber(String text, Class<T> targetClass) {
		if (text == null) {
			throw new IllegalArgumentException("Text must not be null");
		} else if (targetClass == null) {
			throw new IllegalArgumentException("Target class must not be null");
		}
		String trimmed = text.replaceAll("\\p{javaWhitespace}+", "");

		if (targetClass.equals(Byte.class)) {
			return (T) (Byte.valueOf(trimmed));
		} else if (targetClass.equals(Short.class)) {
			return (T) (Short.valueOf(trimmed));
		} else if (targetClass.equals(Integer.class)) {
			return (T) (Integer.valueOf(trimmed));
		} else if (targetClass.equals(Long.class)) {
			return (T) (Long.valueOf(trimmed));
		} else if (targetClass.equals(Float.class)) {
			return (T) Float.valueOf(trimmed);
		} else if (targetClass.equals(Double.class)) {
			return (T) Double.valueOf(trimmed);
		} else {
			throw new IllegalArgumentException(
					"Cannot convert String [" + text + "] to target class [" + targetClass.getName() + "]");
		}
	}