Here you can find the source of formatSeconds(Duration duration)
public static String formatSeconds(Duration duration)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; import java.time.Duration; public class Main { private static final DecimalFormat SECONDS_FORMAT = new DecimalFormat("0.000s"); public static String formatSeconds(Duration duration) { return SECONDS_FORMAT.format(duration.toMillis() / 1000d); }/* w ww. ja v a2 s. c om*/ }