public String format(Duration duration) {
    Long durationInMinutes = duration.toMinutes();
    if (durationInMinutes == 0) {
      return "0";
    }
    boolean isNegative = durationInMinutes < 0;
    Long absDuration = Math.abs(durationInMinutes);

    int days = ((Double) ((double) absDuration / HOURS_IN_DAY / 60)).intValue();
    Long remainingDuration = absDuration - (days * HOURS_IN_DAY * 60);
    int hours = ((Double) (remainingDuration.doubleValue() / 60)).intValue();
    remainingDuration = remainingDuration - (hours * 60);
    int minutes = remainingDuration.intValue();

    return format(days, hours, minutes, isNegative);
  }
public String format ( Duration duration ) { Long durationInMinutes = duration . toMinutes ( ) ; if ( durationInMinutes == 0 ) { return "0" ; } boolean isNegative = durationInMinutes < 0 ; Long absDuration = Math . abs ( durationInMinutes ) ; int days = ( ( Double ) ( ( double ) absDuration / HOURS_IN_DAY / 60 ) ) . intValue ( ) ; Long remainingDuration = absDuration - ( days * HOURS_IN_DAY * 60 ) ; int hours = ( ( Double ) ( remainingDuration . doubleValue ( ) / 60 ) ) . intValue ( ) ; remainingDuration = remainingDuration - ( hours * 60 ) ; int minutes = remainingDuration . intValue ( ) ; return format ( days , hours , minutes , isNegative ) ; }
Return the formatted work duration using the english bundles.
<br>
Example : format(Duration.encode("9d 10h")) -&gt; 10d 2h