List of usage examples for org.joda.time.format PeriodParser parseInto
int parseInto(ReadWritablePeriod period, String periodStr, int position, Locale locale);
From source file:org.apache.tamaya.jodatime.PeriodConverter.java
License:Apache License
@Override public Period convert(String value, ConversionContext context) { String trimmed = Objects.requireNonNull(value).trim(); context.addSupportedFormats(PeriodConverter.class, "PyYmMwWdDThHmMsS"); context.addSupportedFormats(PeriodConverter.class, "Pyyyy-mm-ddThh:mm:ss"); MutablePeriod result = null;/* w w w .ja va 2 s.com*/ PeriodParser format = null; if (isISOFormat(trimmed)) { format = ISO_FORMAT; } else if (isAlternativeFormat(trimmed)) { format = ALTERNATIVE_FORMAT; } if (format != null) { result = new MutablePeriod(); int parseResult = format.parseInto(result, trimmed, 0, Locale.ENGLISH); if (parseResult < 0) { result = null; } } return result != null ? result.toPeriod() : null; }