Code example for ParsePosition

Methods: getErrorIndex

0
     *  
     * @param xmlDateTime the XML date time string 
     */ 
    public static long getTime(String xmlDateTime) {
        // Parse the date time base 
        ParsePosition position = new ParsePosition(0);
        Date date = ISO_8601_BASE.parse(xmlDateTime, position);
        if (date == null) {
            throw new IllegalArgumentException("Invalid XML dateTime value: "
                    + xmlDateTime + " (at position " + position.getErrorIndex()
                    + ")"); 
        } 
 
        // Parse the date time extras 
        Matcher matcher = ISO_8601_EXTRAS.matcher(xmlDateTime
                .substring(position.getIndex()));
        if (!matcher.matches()) {
            // This will match even an empty string as all groups are optional. 
            // Thus a 
            // non-match means invalid content. 
            throw new IllegalArgumentException("Invalid XML dateTime value: "