org.srplib.conversion.StringToFloatConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of srp-conversion-support Show documentation
Show all versions of srp-conversion-support Show documentation
Single Responsibility Principle (SRP) libraries collection
package org.srplib.conversion;
/**
* Converts {@link String} value to {@link Float} value.
*
* @author Q-GMA
*/
public class StringToFloatConverter implements Converter {
/**
* Converts string to float.
*
* @param input a value to convert.
* @return Float value.
* @throws org.srplib.conversion.ConverterException if value can't be converted.
*/
@Override
public Float convert(String input) {
try {
return Float.valueOf(input);
}
catch (NumberFormatException e) {
throw new ConverterException("Can't convert '" + input + "' to float.", e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy