Here you can find the source of formatTimeString(long millisecond)
public static String formatTimeString(long millisecond)
//package com.java2s; public class Main { /**/*w ww . j av a2 s.c o m*/ * Milliseconds -> hh:mm:ss */ public static String formatTimeString(long millisecond) { millisecond = millisecond < 0 ? -millisecond : millisecond; // dateFormat.setTimeZone(TimeZone.getTimeZone("GMT + 0")); //BUG: less than 24 hours // return dateFormat.format(millisecond); int seconds = (int) (millisecond / 1000); StringBuffer result = new StringBuffer(""); int ss = seconds % 60; int mm = seconds / 60 % 60; int hh = seconds / 3600; if (hh == 0) result.append("00"); else if (hh < 10) result.append("0").append(hh); else result.append(hh); result.append(":"); if (mm == 0) result.append("00"); else if (mm < 10) result.append("0").append(mm); else result.append(mm); result.append(":"); if (ss == 0) result.append("00"); else if (ss < 10) result.append("0").append(ss); else result.append(ss); return result.toString(); } }