/** * Parses the text to a builder. * * <p>This parses to a {@code DateTimeBuilder} but does not require the input to be fully parsed. * * <p>This method does not throw {@link DateTimeParseException}. Instead, errors are returned * within the state of the specified parse position. Callers must check for errors before using * the context. * * <p>This method may throw some other {@code DateTimeException} if a date/time problem occurs. * * @param text the text to parse, not null * @param position the position to parse from, updated with length parsed and the index of any * error, not null * @return the parsed text, null only if the parse results in an error * @throws IndexOutOfBoundsException if the position is invalid * @throws DateTimeParseException if the parse fails * @throws DateTimeException if there is a date/time problem */ public DateTimeBuilder parseToBuilder(CharSequence text, ParsePosition position) { Objects.requireNonNull(text, "text"); Objects.requireNonNull(position, "position"); DateTimeParseContext context = new DateTimeParseContext(locale, symbols); int pos = position.getIndex(); pos = printerParser.parse(context, text, pos); if (pos < 0) { position.setErrorIndex(~pos); return null; } position.setIndex(pos); return context.toBuilder(); }