当我使用PeriodFormatter时,如下所示
PeriodFormatter formatter = new PeriodFormatterBuilder().appendHours()
.appendLiteral(":").appendMinutes().appendLiteral(":")
.appendSeconds().toFormatter();我得到的输出是4:39:9,这意味着4小时39分9秒。
如何修改格式化程序以生成04:39:09?谢谢
发布于 2012-04-07 02:32:43
添加.printZeroAlways()和.minimumPrintedDigits(2)
PeriodFormatter formatter = new PeriodFormatterBuilder()
.printZeroAlways()
.minimumPrintedDigits(2)
.appendHours()
.appendLiteral(":")
.appendMinutes()
.appendLiteral(":")
.appendSeconds()
.toFormatter();发布于 2012-04-07 02:31:22
看看minimumPrintedDigits吧。它应该做你想做的事情。
http://joda-time.sourceforge.net/api-release/org/joda/time/format/PeriodFormatterBuilder.html#minimumPrintedDigits(int)
https://stackoverflow.com/questions/10047188
复制相似问题