Code example for ParsePosition

Methods: getErrorIndex, getIndex

0
     * @see #format 
     * @stable ICU 2.0 
     */ 
    //Bug 4375399 [Richard/GCL] 
    public Number parse(String text) throws ParseException {
        ParsePosition parsePosition = new ParsePosition(0);
        Number result = parse(text, parsePosition);
        if (parsePosition.getIndex() == 0) {
            throw new ParseException("Unparseable number: \"" + text + '"',
                                     parsePosition.getErrorIndex());
        } 
        return result;
    } 
 
    /** 
     * Parses text from the given string as a CurrencyAmount.  Unlike 
     * the parse() method, this method will attempt to parse a generic 
     * currency name, searching for a match of this object's locale's 
     * currency display names, or for a 3-letter ISO currency code. 
     * This method will fail if this format is not a currency format, 
     * that is, if it does not contain the currency pattern symbol