Code example for ParsePosition

Methods: getErrorIndex, getIndex

0
            } 
            if (parsed != null && pp.getIndex() == timestampStr.length() + 5) {
                working.setTime(parsed);
            } 
            else { 
                pp = new ParsePosition(0);
                parsed = defaultDateFormat.parse(timestampStr, pp);
                // note, length checks are mandatory for us since 
                // SimpleDateFormat methods will succeed if less than 
                // full string is matched.  They will also accept, 
                // despite "leniency" setting, a two-digit number as 
                // a valid year (e.g. 22:04 will parse as 22 A.D.) 
                // so could mistakenly confuse an hour with a year, 
                // if we don't insist on full length parsing. 
                if (parsed != null && pp.getIndex() == timestampStr.length()) {
                    working.setTime(parsed);
                } else { 
                    throw new ParseException(
                            "Timestamp could not be parsed with older or recent DateFormat", 
                            pp.getErrorIndex());
                } 
            } 
        } 
        return working;
    }