DateUtils { public static String ms2Time(long ms) { long day = ms / DD; long hour = (ms - day * DD) / HH; long minute = (ms - day * DD - hour * HH) / MI; long second = (ms - day * DD - hour * HH - minute * MI) / SS; String strDay = day < CONSTANT_10 ? "0" + day : "" + day; String strHour = hour < CONSTANT_10 ? "0" + hour : "" + hour; String strMinute = minute < CONSTANT_10 ? "0" + minute : "" + minute; String strSecond = second < CONSTANT_10 ? "0" + second : "" + second; strDay = (StringUtils.equals(strDay, "00")) ? "" : strDay + ":"; return strDay + strHour + ":" + strMinute + ":" + strSecond; }  static long getCollectTimeInLong(Date date); static Date convertToServerDate(String userTimeZone, Date userDate); static Date convertToUserDate(String userTimeZone, Date serverDate); static String dateToString(Date date); static Map<String, String> getFilteredTimeZoneMap(); static Date toSimpleDate(String strDate); static Date toDate(String strDate); static Date addDay(Date date, int days); static String ms2Time(long ms); static long timeToMs(int day, int hour, int min, int sec); static boolean compareDateEndWithMinute(Date d1, Date d2);  }
@Test public void testMs2Time() { final long secTime = 1000; long timeMs = 10 * secTime; String durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("00:00:10")); timeMs = 10 * secTime + 33; durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("00:00:10")); timeMs = 10 * secTime; durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("00:00:10")); timeMs = 10 * secTime + 3 * 60 * secTime; durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("00:03:10")); timeMs = timeMs + 10 * 60 * secTime; durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("00:13:10")); timeMs = timeMs + 3 * 60 * 60 * secTime; durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("03:13:10")); timeMs = timeMs + 10 * 60 * 60 * secTime; durationStr = DateUtils.ms2Time(timeMs); assertThat(durationStr, is("13:13:10")); }