我想将像“8y5d”或“-6y144d”这样的字符串解析成一个joda时间段对象。谢谢
问问题
1928 次
1 回答
11
PeriodFormatter yearsAndMonths = new PeriodFormatterBuilder()
.printZeroRarelyFirst()
.appendYears()
.appendSuffix("y", "y")
.printZeroRarelyLast()
.appendDays()
.appendSuffix("d", "d")
.toFormatter();
System.out.println(yearsAndMonths.parsePeriod("8y5d").toDurationFrom(new DateTime()).getStandardDays());
于 2012-08-30T21:16:09.230 回答