Code example for DecimalFormat

Methods: getDecimalFormatSymbolssetDecimalFormatSymbolssetParseBigDecimal

0
package orm.fieldtype; 
 
import java.math.BigDecimal; 
import java.text.DecimalFormat; 
import java.text.DecimalFormatSymbols; 
import java.text.ParseException; 
 
public class NumberType extends AbstractFieldTypeMetadata { 
 
	private static DecimalFormat format = new DecimalFormat("#0.0#");
 
	static { 
		DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
		symbols.setDecimalSeparator('.');
		format.setDecimalFormatSymbols(symbols);
		format.setParseBigDecimal(true);
	} 
 
	@Override 
	public BigDecimal toBigDecimal(String value) {
 
		try { 
			return (BigDecimal) format.parse(value);
		} catch (ParseException e) {
Stop searching for code, let great code find you!  Add Codota to your java IDE