private StrategyAndWidth literal() { boolean activeQuote = false; final StringBuilder sb = new StringBuilder(); while (currentIdx < pattern.length()) { final char c = pattern.charAt(currentIdx); if (!activeQuote && isFormatLetter(c)) { break; } else if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) { activeQuote = !activeQuote; continue; } ++currentIdx; sb.append(c); } if (activeQuote) { throw new IllegalArgumentException("Unterminated quote"); } final String formatField = sb.toString(); return new StrategyAndWidth(new CopyQuotedStrategy(formatField), formatField.length()); } }
/** * Parse a formatted date string according to the format. Updates the Calendar with parsed fields. * Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed. * Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to * the offset of the source text which does not match the supplied format. * * @param source The text to parse. * @param pos On input, the position in the source to start parsing, on output, updated position. * @param calendar The calendar into which to set parsed fields. * @return true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated) * @throws IllegalArgumentException when Calendar has been set to be not lenient, and a parsed field is * out of range. */ @Override public boolean parse(final String source, final ParsePosition pos, final Calendar calendar) { final ListIterator<StrategyAndWidth> lt = patterns.listIterator(); while (lt.hasNext()) { final StrategyAndWidth strategyAndWidth = lt.next(); final int maxWidth = strategyAndWidth.getMaxWidth(lt); if (!strategyAndWidth.strategy.parse(this, calendar, source, pos, maxWidth)) { return false; } } return true; }
/** * Parse a formatted date string according to the format. Updates the Calendar with parsed fields. * Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed. * Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to * the offset of the source text which does not match the supplied format. * * @param source The text to parse. * @param pos On input, the position in the source to start parsing, on output, updated position. * @param calendar The calendar into which to set parsed fields. * @return true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated) * @throws IllegalArgumentException when Calendar has been set to be not lenient, and a parsed field is * out of range. */ @Override public boolean parse(final String source, final ParsePosition pos, final Calendar calendar) { final ListIterator<StrategyAndWidth> lt = patterns.listIterator(); while (lt.hasNext()) { final StrategyAndWidth strategyAndWidth = lt.next(); final int maxWidth = strategyAndWidth.getMaxWidth(lt); if (!strategyAndWidth.strategy.parse(this, calendar, source, pos, maxWidth)) { return false; } } return true; }
/** * Parse a formatted date string according to the format. Updates the Calendar with parsed fields. * Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed. * Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to * the offset of the source text which does not match the supplied format. * * @param source The text to parse. * @param pos On input, the position in the source to start parsing, on output, updated position. * @param calendar The calendar into which to set parsed fields. * @return true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated) * @throws IllegalArgumentException when Calendar has been set to be not lenient, and a parsed field is * out of range. */ @Override public boolean parse(final String source, final ParsePosition pos, final Calendar calendar) { final ListIterator<StrategyAndWidth> lt = patterns.listIterator(); while (lt.hasNext()) { final StrategyAndWidth strategyAndWidth = lt.next(); final int maxWidth = strategyAndWidth.getMaxWidth(lt); if (!strategyAndWidth.strategy.parse(this, calendar, source, pos, maxWidth)) { return false; } } return true; }
/** * Parse a formatted date string according to the format. Updates the Calendar with parsed fields. * Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed. * Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to * the offset of the source text which does not match the supplied format. * * @param source The text to parse. * @param pos On input, the position in the source to start parsing, on output, updated position. * @param calendar The calendar into which to set parsed fields. * @return true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated) * @throws IllegalArgumentException when Calendar has been set to be not lenient, and a parsed field is * out of range. */ @Override public boolean parse(final String source, final ParsePosition pos, final Calendar calendar) { final ListIterator<StrategyAndWidth> lt = patterns.listIterator(); while (lt.hasNext()) { final StrategyAndWidth strategyAndWidth = lt.next(); final int maxWidth = strategyAndWidth.getMaxWidth(lt); if (!strategyAndWidth.strategy.parse(this, calendar, source, pos, maxWidth)) { return false; } } return true; }
private StrategyAndWidth literal() { boolean activeQuote = false; final StringBuilder sb = new StringBuilder(); while (currentIdx < pattern.length()) { final char c = pattern.charAt(currentIdx); if (!activeQuote && isFormatLetter(c)) { break; } else if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) { activeQuote = !activeQuote; continue; } ++currentIdx; sb.append(c); } if (activeQuote) { throw new IllegalArgumentException("Unterminated quote"); } final String formatField = sb.toString(); return new StrategyAndWidth(new CopyQuotedStrategy(formatField), formatField.length()); } }
private StrategyAndWidth literal() { boolean activeQuote = false; final StringBuilder sb = new StringBuilder(); while (currentIdx < pattern.length()) { final char c = pattern.charAt(currentIdx); if (!activeQuote && isFormatLetter(c)) { break; } else if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) { activeQuote = !activeQuote; continue; } ++currentIdx; sb.append(c); } if (activeQuote) { throw new IllegalArgumentException("Unterminated quote"); } final String formatField = sb.toString(); return new StrategyAndWidth(new CopyQuotedStrategy(formatField), formatField.length()); } }
private StrategyAndWidth literal() { boolean activeQuote = false; final StringBuilder sb = new StringBuilder(); while (currentIdx < pattern.length()) { final char c = pattern.charAt(currentIdx); if (!activeQuote && isFormatLetter(c)) { break; } else if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) { activeQuote = !activeQuote; continue; } ++currentIdx; sb.append(c); } if (activeQuote) { throw new IllegalArgumentException("Unterminated quote"); } final String formatField = sb.toString(); return new StrategyAndWidth(new CopyQuotedStrategy(formatField), formatField.length()); } }
private StrategyAndWidth letterPattern(final char c) { final int begin = currentIdx; while (++currentIdx < pattern.length()) { if (pattern.charAt(currentIdx) != c) { break; } } final int width = currentIdx - begin; return new StrategyAndWidth(getStrategy(c, width, definingCalendar), width); }
private StrategyAndWidth letterPattern(final char c) { final int begin = currentIdx; while (++currentIdx < pattern.length()) { if (pattern.charAt(currentIdx) != c) { break; } } final int width = currentIdx - begin; return new StrategyAndWidth(getStrategy(c, width, definingCalendar), width); }
private StrategyAndWidth letterPattern(final char c) { final int begin = currentIdx; while (++currentIdx < pattern.length()) { if (pattern.charAt(currentIdx) != c) { break; } } final int width = currentIdx - begin; return new StrategyAndWidth(getStrategy(c, width, definingCalendar), width); }
private StrategyAndWidth letterPattern(final char c) { final int begin = currentIdx; while (++currentIdx < pattern.length()) { if (pattern.charAt(currentIdx) != c) { break; } } final int width = currentIdx - begin; return new StrategyAndWidth(getStrategy(c, width, definingCalendar), width); }