Example usage for java.text DecimalFormat getMaximumFractionDigits

List of usage examples for java.text DecimalFormat getMaximumFractionDigits

Introduction

In this page you can find the example usage for java.text DecimalFormat getMaximumFractionDigits.

Prototype

@Override
public int getMaximumFractionDigits() 

Source Link

Document

Gets the maximum number of digits allowed in the fraction portion of a number.

Usage

From source file:br.com.nordestefomento.jrimum.utilix.Field.java

@SuppressWarnings("unchecked")
private void readDecimalField(String valueAsString) {

    DecimalFormat decimalFormat = (DecimalFormat) format;

    try {//from w ww  . ja  v  a2s . c om

        Long parsedValue = (Long) format.parseObject(valueAsString);
        BigDecimal decimalValue = new BigDecimal(parsedValue.longValue());
        decimalValue = decimalValue.movePointLeft(decimalFormat.getMaximumFractionDigits());

        value = (G) decimalValue;

    } catch (ParseException e) {

        getGenericReadError(e, valueAsString);
    }
}

From source file:org.jrimum.utilix.text.Field.java

/**
 * L campos de valores decimais. O parse  feito atravs de formatadores de nmeros decimais.
 * @param valueAsString/*  www  .ja v a  2  s  . co m*/
 */
@SuppressWarnings("unchecked")
private void readDecimalField(String valueAsString) {

    DecimalFormat decimalFormat = (DecimalFormat) format;

    try {

        Long parsedValue = (Long) format.parseObject(valueAsString);
        BigDecimal decimalValue = new BigDecimal(parsedValue.longValue());
        decimalValue = decimalValue.movePointLeft(decimalFormat.getMaximumFractionDigits());

        value = (G) decimalValue;

    } catch (ParseException e) {

        getGenericReadError(e, valueAsString);
    }
}