防止Joda-Time打印负数

时间:2016-06-04 15:35:08

标签: android jodatime

我使用以下代码制作我想要的String,但如果Period已通过,则会打印负号。只有在Period通过时,我才会显示零数而不是负数。

Period period = new Period(new LocalDateTime(System.currentTimeMillis(), DateTimeZone.forID("Iran")), new LocalDateTime(myEndTime, DateTimeZone.forID("Iran")), PeriodType.yearMonthDayTime());

new PeriodFormatterBuilder().rejectSignedValues(true).printZeroAlways().minimumPrintedDigits(2).appendHours().appendSuffix(":").minimumPrintedDigits(2).appendMinutes().toFormatter().print(period);

注意:我在Android应用中使用Joda-Time而JDKv7正在使用。

0 个答案:

没有答案
相关问题