@Override
public int parseInto(ReadWritablePeriod period, String text, int position, Locale locale)
{
int bestValidPos = position;
ReadWritablePeriod bestValidPeriod = null;
int bestInvalidPos = position;
for (PeriodParser parser : parsers) {
ReadWritablePeriod parsedPeriod = new MutablePeriod();
int parsePos = parser.parseInto(parsedPeriod, text, position, locale);
if (parsePos >= position) {
if (parsePos > bestValidPos) {
bestValidPos = parsePos;
bestValidPeriod = parsedPeriod;
if (parsePos >= text.length()) {
break;
}
}
}
else if (parsePos < 0) {
parsePos = ~parsePos;
if (parsePos > bestInvalidPos) {
bestInvalidPos = parsePos;
}
}
}
if (bestValidPos > position || (bestValidPos == position)) {
// Restore the state to the best valid parse.
if (bestValidPeriod != null) {
period.setPeriod(bestValidPeriod);
}
return bestValidPos;
}
return ~bestInvalidPos;
}
DateTimeUtils.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:presto
作者:
评论列表
文章目录