code: public static String timeToString(long start, long finish) {
  
      Duration duration = new Duration(finish - start); // in milliseconds
      PeriodFormatter formatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d")
          .appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").appendSeconds()
          .appendSuffix("s").appendMillis().appendSuffix("ms").toFormatter();
  
      return formatter.print(duration.toPeriod());
  
    }
docs: Generic method to convert the milliseconds into the elapsed time string.
  
  @param start Start timestamp.
  @param finish End timestamp.
  @return String representation of the elapsed time.