Here you can find the source of printTimeMap(Map
public static void printTimeMap(Map<String, Long> timeMap)
//package com.java2s; //License from project: LGPL import java.util.Map; import java.util.concurrent.TimeUnit; public class Main { public static void printTimeMap(Map<String, Long> timeMap) { System.out.println(toStringTimeMap(timeMap)); }/*from w w w. ja v a 2s.co m*/ public static String toStringTimeMap(Map<String, Long> timeMap) { StringBuilder sb = new StringBuilder(); for (String stamp : timeMap.keySet()) { sb.append(stamp + ": \t" + formatMillis(timeMap.get(stamp)) + "\n"); } return sb.toString(); } public static String formatMillis(long millis) { return String.format("%dd:%dh:%dm:%ds:%dms", TimeUnit.MILLISECONDS.toDays(millis), TimeUnit.MILLISECONDS.toHours(millis) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(millis)), TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)), TimeUnit.MILLISECONDS.toSeconds(millis) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)), millis - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millis))); } }