Code example for ParsePosition

Methods: getErrorIndex

0
                pair.setFormat(this);
                pair.setStartDate(mFirstFormat.parse(dateStrings[0]));
 
                boolean startLeniet = mSecondFormat.isLenient();
                mSecondFormat.setLenient(false);
                ParsePosition position = new ParsePosition(0);
                Date temp = mSecondFormat.parse(dateStrings[1],position);
                if (temp == null) {
                    // the error index should be the first character that's part of the 
                    // end format so just back it up by 1 and continue. 
                    temp = mSecondFormat.parse(dateStrings[1].substring(0, position.getErrorIndex()-1));
                } 
                mSecondFormat.setLenient(startLeniet); // restore original leniency.
                pair.setEndDate(temp);
                return pair;
            } 
    } 
 
        private Date mStart;
        private Date mEnd;
        private PairFormat mFormat;