Here you can find the source of toTimeExpression(long ms, int frames)
public static String toTimeExpression(long ms, int frames)
//package com.java2s; //License from project: Apache License public class Main { public static String toTimeExpression(long ms) { return toTimeExpression(ms, -1); }//from www . ja va 2 s.c o m public static String toTimeExpression(long ms, int frames) { String minus = ms >= 0 ? "" : "-"; ms = Math.abs(ms); long hours = ms / 1000 / 60 / 60; ms -= hours * 1000 * 60 * 60; long minutes = ms / 1000 / 60; ms -= minutes * 1000 * 60; long seconds = ms / 1000; ms -= seconds * 1000; if (frames >= 0) { return String.format("%s%02d:%02d:%02d:%d", minus, hours, minutes, seconds, frames); } else { return String.format("%s%02d:%02d:%02d.%03d", minus, hours, minutes, seconds, ms); } } }