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 ( ) ) ; }
Generic method to convert the milliseconds into the elapsed time string .