5

PeriodFormatter以下のように使用すると

PeriodFormatter formatter = new PeriodFormatterBuilder().appendHours()
                .appendLiteral(":").appendMinutes().appendLiteral(":")
                .appendSeconds().toFormatter();

4:39:94 時間 39 分 9 秒を意味する出力が得られます。

フォーマッタを変更して生成する方法は04:39:09? ありがとう

4

2 に答える 2

16

追加.printZeroAlways()して.minimumPrintedDigits(2):

    PeriodFormatter formatter = new PeriodFormatterBuilder()
        .printZeroAlways()
        .minimumPrintedDigits(2)
        .appendHours()
        .appendLiteral(":")
        .appendMinutes()
        .appendLiteral(":")
        .appendSeconds()
        .toFormatter();
于 2012-04-06T18:32:42.693 に答える
0

minimumPrintedDigits を見てください。それはあなたが望むことをするべきです。

http://joda-time.sourceforge.net/api-release/org/joda/time/format/PeriodFormatterBuilder.html#minimumPrintedDigits(int)

于 2012-04-06T18:31:22.180 に答える