Code example for NumberFormat

Methods: parse

0
    public EvaluationCommand parse(MathExpressionReader reader) {
 
        final ParsePosition position =
                new ParsePosition(reader.getReadPosition());
 
        final Number number =
                NUMBER_FORMAT.parse(reader.getExpression(), position);
 
        if (position.getErrorIndex() < 0) {
 
            final int readPosition = position.getIndex();
            reader.setReadPosition(readPosition);
 
            return new EvaluateNumberCommand( 
                    new BigDecimal(number.doubleValue()));
        } 
 
        return null; 
    } 
}