Example usage for java.text NumberFormat parseObject

List of usage examples for java.text NumberFormat parseObject

Introduction

In this page you can find the example usage for java.text NumberFormat parseObject.

Prototype

public Object parseObject(String source) throws ParseException 

Source Link

Document

Parses text from the beginning of the given string to produce an object.

Usage

From source file:org.apache.empire.struts2.jsp.controls.TextInputControl.java

protected Object parseDecimal(String s, NumberFormat nf) {
    // Try to convert
    try {//  w  w w.  ja v  a  2 s .co  m
        // Check for characters
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) >= 'A')
                return error(FieldErrors.InputNoNumberFormat, null, s);
        }
        // Parse String
        return nf.parseObject(s);
    } catch (Exception e) {
        return error(FieldErrors.InputNoNumberFormat, null, s);
    }
}