Here you can find the source of millisToHMSShort(long millis)
public static String millisToHMSShort(long millis)
//package com.java2s; //License from project: Apache License public class Main { private static final String SHORT_FORMAT = millisToHMS(0); public static String millisToHMSShort(long millis) { boolean minus = false; if (millis < 0) { minus = true;/* ww w.j a v a 2 s .com*/ millis = -millis; } String hms = millisToHMS(millis); int i; for (i = 0; i < hms.length() - 1; i++) { if (hms.charAt(i) != SHORT_FORMAT.charAt(i)) { break; } } String hmsShort = hms.substring(i); return minus ? "-" + hmsShort : hmsShort; } public static String millisToHMS(long millis) { boolean minus = false; if (millis < 0) { minus = true; millis = -millis; } long s = millis / 1000; long m = s / 60; long h = m / 60; String hms = String.format("%02d:%02d:%02d", h, m % 60, s % 60); return minus ? "-" + hms : hms; } }