Here you can find the source of parseDuration(final Duration duration)
public static String parseDuration(final Duration duration)
//package com.java2s; //License from project: Open Source License import java.time.Duration; public class Main { public static String parseDuration(final Duration duration) { return parseTimeString(duration.toString()); }// www . java 2 s. co m public static String parseTimeString(final String timestring) { String ts = timestring.substring(2); if (ts.contains("S")) ts = ts.substring(0, ts.indexOf("S")); if (ts.contains("H")) ts = ts.replace("H", ":"); else ts = "0:" + ts; if (ts.contains("M")) ts = ts.replace("M", ":"); else ts = ts.substring(0, ts.indexOf(":") + 1) + "0:" + ts.substring(ts.indexOf(":") + 1); return ts; } }