Android examples for java.util:Date Time
get Time Duration in format of 00:00:00
public class Main { public static String getVConfDuration(long startTime, long endTime) { long duration = endTime - startTime; if (duration <= 0) { return "00:00:00"; }/*from ww w.j a v a2 s . co m*/ long h = duration / 60 / 60 / 1000; long moH = duration % (60 * 60 * 1000); long m = moH / 60 / 1000; long moM = moH % (60 * 1000); long s = moM / 1000; StringBuffer sb = new StringBuffer(); if (h < 10) { sb.append(0); } sb.append(h); sb.append(":"); if (m < 10) { sb.append(0); } sb.append(m); sb.append(":"); if (s < 10) { sb.append(0); } sb.append(s); return sb.toString(); } }