Example usage for org.joda.time.format PeriodFormatterBuilder printZeroAlways

List of usage examples for org.joda.time.format PeriodFormatterBuilder printZeroAlways

Introduction

In this page you can find the example usage for org.joda.time.format PeriodFormatterBuilder printZeroAlways.

Prototype

public PeriodFormatterBuilder printZeroAlways() 

Source Link

Document

Always print zero values for the next and following appended fields, even if the period doesn't support it.

Usage

From source file:ch.eitchnet.android.util.JodaHelper.java

License:Open Source License

public static String toHourMinute(Duration duration) {
    PeriodFormatterBuilder builder = new PeriodFormatterBuilder();
    builder.printZeroAlways();
    if (duration.isShorterThan(Duration.ZERO))
        builder.appendLiteral("-");
    builder.minimumPrintedDigits(2).appendHours().appendLiteral(":").minimumPrintedDigits(2).appendMinutes();
    return builder.toFormatter().print(new Period(Math.abs(duration.getMillis())));
}