public static String toHumanReadableString(final String iso8601Duration){
  String str="";
  if (iso8601Duration.matches("P\\d+[YMD].+")) {
    str="inf.";
  }
 else {
    String hours=getHours(iso8601Duration), minutes=getMinutes(iso8601Duration), seconds=getSeconds(iso8601Duration);
    if (hours != null) {
      str=hours;
      if (minutes != null && minutes.length() == 1) {
        minutes="0" + minutes;
      }
    }
    if (str.isEmpty())     str=minutes;
 else     str+=":" + minutes;
    if (str.isEmpty())     str=seconds;
 else     str+=":" + seconds;
  }
  return str;
}

public static String toHumanReadableString ( final String iso8601Duration ) { String str = "" ; if ( iso8601Duration . matches ( "P\\d+[YMD].+" ) ) { str = "inf." ; } else { String hours = getHours ( iso8601Duration ) , minutes = getMinutes ( iso8601Duration ) , seconds = getSeconds ( iso8601Duration ) ; if ( hours != null ) { str = hours ; if ( minutes != null && minutes . length ( ) == 1 ) { minutes = "0" + minutes ; } } if ( str . isEmpty ( ) ) str = minutes ; else str += ":" + minutes ; if ( str . isEmpty ( ) ) str = seconds ; else str += ":" + seconds ; } return str ; }
converts the supplies iso 8601 duration into a human readable string . if the supplied duration is greater than 1 day , then it will return " inf . " .
