Example usage for org.joda.time Period plusMillis

List of usage examples for org.joda.time Period plusMillis

Introduction

In this page you can find the example usage for org.joda.time Period plusMillis.

Prototype

public Period plusMillis(int millis) 

Source Link

Document

Returns a new period plus the specified number of millis added.

Usage

From source file:elw.web.FormatTool.java

License:Open Source License

public String formatDuration(final long timeMillis) {
    final Period period = new Period();
    final Period periodNorm = period.plusMillis((int) Math.abs(timeMillis)).normalizedStandard();

    if (periodNorm.getYears() > 0) {
        return lookupPeriodFormatter("y").print(periodNorm);
    } else if (periodNorm.getMonths() > 0) {
        return lookupPeriodFormatter("M").print(periodNorm);
    } else if (periodNorm.getDays() > 0) {
        return lookupPeriodFormatter("d").print(periodNorm);
    } else if (periodNorm.getHours() > 0) {
        return lookupPeriodFormatter("H").print(periodNorm);
    } else if (periodNorm.getMinutes() > 0) {
        return lookupPeriodFormatter("m").print(periodNorm);
    } else {/*from  ww w .j a v  a  2 s. c  o  m*/
        //  LATER sometimes durations less than one second occur
        return lookupPeriodFormatter("s").print(periodNorm);
    }
}