public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { PeriodParser[] parsers = iParsers; if (parsers == null) { throw new UnsupportedOperationException(); } int len = parsers.length; for (int i=0; i<len && position >= 0; i++) { position = parsers[i].parseInto(period, periodStr, position, locale); } return position; }
public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { PeriodParser[] parsers = iParsers; if (parsers == null) { throw new UnsupportedOperationException(); } int len = parsers.length; for (int i=0; i<len && position >= 0; i++) { position = parsers[i].parseInto(period, periodStr, position, locale); } return position; }
public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { return getParser(locale).parseInto(period, periodStr, position, locale); }
public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { return getParser(locale).parseInto(period, periodStr, position, locale); }
int parsePos = parser.parseInto(parsedPeriod, text, position, locale); if (parsePos >= position) { if (parsePos > bestValidPos) {
/** * Parses a period from the given text, returning a new MutablePeriod. * * @param text text to parse * @return parsed value in a MutablePeriod object * @throws IllegalArgumentException if any field is out of range */ public MutablePeriod parseMutablePeriod(String text) { checkParser(); MutablePeriod period = new MutablePeriod(0, iParseType); int newPos = getParser().parseInto(period, text, 0, iLocale); if (newPos >= 0) { if (newPos >= text.length()) { return period; } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
/** * Parses a period from the given text, returning a new MutablePeriod. * * @param text text to parse * @return parsed value in a MutablePeriod object * @throws IllegalArgumentException if any field is out of range */ public MutablePeriod parseMutablePeriod(String text) { checkParser(); MutablePeriod period = new MutablePeriod(0, iParseType); int newPos = getParser().parseInto(period, text, 0, iLocale); if (newPos >= 0) { if (newPos >= text.length()) { return period; } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
/** * Parses a period from the given text, at the given position, saving the * result into the fields of the given ReadWritablePeriod. If the parse * succeeds, the return value is the new text position. Note that the parse * may succeed without fully reading the text. * <p> * The parse type of the formatter is not used by this method. * <p> * If it fails, the return value is negative, but the period may still be * modified. To determine the position where the parse failed, apply the * one's complement operator (~) on the return value. * * @param period a period that will be modified * @param text text to parse * @param position position to start parsing from * @return new position, if negative, parse failed. Apply complement * operator (~) to get position of failure * @throws IllegalArgumentException if any field is out of range */ public int parseInto(ReadWritablePeriod period, String text, int position) { checkParser(); checkPeriod(period); return getParser().parseInto(period, text, position, iLocale); }
/** * Parses a period from the given text, at the given position, saving the * result into the fields of the given ReadWritablePeriod. If the parse * succeeds, the return value is the new text position. Note that the parse * may succeed without fully reading the text. * <p> * The parse type of the formatter is not used by this method. * <p> * If it fails, the return value is negative, but the period may still be * modified. To determine the position where the parse failed, apply the * one's complement operator (~) on the return value. * * @param period a period that will be modified * @param text text to parse * @param position position to start parsing from * @return new position, if negative, parse failed. Apply complement * operator (~) to get position of failure * @throws IllegalArgumentException if any field is out of range */ public int parseInto(ReadWritablePeriod period, String text, int position) { checkParser(); checkPeriod(period); return getParser().parseInto(period, text, position, iLocale); }
public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { PeriodParser[] parsers = iParsers; if (parsers == null) { throw new UnsupportedOperationException(); } int len = parsers.length; for (int i=0; i<len && position >= 0; i++) { position = parsers[i].parseInto(period, periodStr, position, locale); } return position; }
String periodString = "98d 01h 23m 45s"; PeriodParser parser = new PeriodFormatterBuilder() .appendDays().appendSuffix("d ") .appendHours().appendSuffix("h ") .appendMinutes().appendSuffix("m ") .appendSeconds().appendSuffix("s ") .toParser(); MutablePeriod period = new MutablePeriod(); parser.parseInto(period, periodString, 0, Locale.getDefault()); long millis = period.toDurationFrom(new DateTime(0)).getMillis();
/** * Parses a period from the given text, returning a new MutablePeriod. * * @param text text to parse * @return parsed value in a MutablePeriod object * @throws IllegalArgumentException if any field is out of range */ public MutablePeriod parseMutablePeriod(String text) { checkParser(); MutablePeriod period = new MutablePeriod(0, iParseType); int newPos = getParser().parseInto(period, text, 0, iLocale); if (newPos >= 0) { if (newPos >= text.length()) { return period; } } else { newPos = ~newPos; } throw new IllegalArgumentException(FormatUtils.createErrorMessage(text, newPos)); }
/** * Parses a period from the given text, at the given position, saving the * result into the fields of the given ReadWritablePeriod. If the parse * succeeds, the return value is the new text position. Note that the parse * may succeed without fully reading the text. * <p> * The parse type of the formatter is not used by this method. * <p> * If it fails, the return value is negative, but the period may still be * modified. To determine the position where the parse failed, apply the * one's complement operator (~) on the return value. * * @param period a period that will be modified * @param text text to parse * @param position position to start parsing from * @return new position, if negative, parse failed. Apply complement * operator (~) to get position of failure * @throws IllegalArgumentException if any field is out of range */ public int parseInto(ReadWritablePeriod period, String text, int position) { checkParser(); checkPeriod(period); return getParser().parseInto(period, text, position, iLocale); }
public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { return getParser(locale).parseInto(period, periodStr, position, locale); }
public int parseInto( ReadWritablePeriod period, String periodStr, int position, Locale locale) { return getParser(locale).parseInto(period, periodStr, position, locale); }
@Override public Period load(ParseableDurationForLocale parseableDurationForLocale) throws Exception { MutablePeriod period = new MutablePeriod(); PERIOD_PARSER.parseInto(period, parseableDurationForLocale.duration, 0, parseableDurationForLocale.locale); return period.toPeriod(); } });
@Override public Period load(ParseableDurationForLocale parseableDurationForLocale) throws Exception { MutablePeriod period = new MutablePeriod(); PERIOD_PARSER.parseInto(period, parseableDurationForLocale.duration, 0, parseableDurationForLocale.locale); return period.toPeriod(); } });