List of usage examples for org.joda.time Period plusMillis
public Period plusMillis(int millis)
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); } }