我有以下期间1个月5天22小时35分39秒,我想要格式化为35天22小时35分39秒。使用以下格式,月份刚刚删除,并没有被添加到天然而,当:显示天数,小时,分钟和秒数
PeriodFormatter formatter = new PeriodFormatterBuilder()
.printZeroAlways()
.appendDays().appendSuffix(" d ")
.appendHours().appendSuffix(" h ")
.appendMinutes().appendSuffix(" m ")
.appendSeconds().appendSuffix(" s ")
.toFormatter();
经过一番搜索,我发现一个应该使用normalizedStandard()方法的时期,但在使用它与period.normalizedStandard(PeriodType.dayTime())
我收到以下错误:
java.lang.UnsupportedOperationException: Field is not supported
at org.joda.time.PeriodType.setIndexedField(PeriodType.java:690)
at org.joda.time.Period.withMonths(Period.java:851)
at org.joda.time.Period.normalizedStandard(Period.java:1541)
at amadeus.bid.wicket.markup.html.CountDownLabel.onComponentTagBody(CountDownLabel.java:34)
任何想法?
也许thsi帮助http://stackoverflow.com/questions/1440557/joda-time-period-to-string – Thariama 2010-11-10 13:42:08
您使用的月份和分钟相同的后缀。 – 2010-11-10 14:04:10
吉尔伯特:抱歉意味着要删除它。 – Kristoffer 2010-11-15 07:35:20