DateTimeUtils { public static String millisecondsToHumanTime(long period) { if (period % MILLIS_IN_SECOND >= HALF_MILLIS_IN_SECOND) { period += MILLIS_IN_SECOND; } period /= MILLIS_IN_SECOND; long secs = period % SECONDS_IN_MINUTE; period /= SECONDS_IN_MINUTE; long mins = period % MINUTES_IN_HOUR; period /= MINUTES_IN_HOUR; long hours = period; return String.format("%02d:%02d:%02d (hh:mm:ss)", hours, mins, secs); } private  DateTimeUtils(); static String timestampToHumanDateAndTimeLocal(long timestamp); static String timestampToHumanDateAndTimeAde(long timestamp); static String timestampToHumanDateAndTimeUTC(long timestamp); static String millisecondsToHumanTime(long period); static String millisecondsToDecimalHumanTime(long period); static long getDayStartTimeLocal(long startTime); static String timestampToHumanDateAndTimeAndStampLocal(long time); static String timestampToHumanDateAndTimeAndStampUTC(long time); static long getTimeStampLocal(int year, int month, int day, double frac); static Date getCurrentDate(); static TimeZone parseTimeZone(String id); static SimpleDateFormat getNewGmtSimpleDateFormat(String format); static SimpleDateFormat getNewGmtSimpleDateFormat(String format, boolean lenient); static Calendar getGmtGregorianCalendar(); static Calendar getGmtGregorianCalendar(int year, int month, int dayOfMonth); static long parseDuration(String strDuration); static final long SECONDS_IN_MINUTE; static final long MINUTES_IN_HOUR; static final long HOURS_IN_DAY; static final long DAYS_IN_WEEK; static final long MILLIS_IN_SECOND; static final long HALF_MILLIS_IN_SECOND; static final long MILLIS_IN_MINUTE; static final long MILLIS_IN_HOUR; static final long MILLIS_IN_DAY; static final long MILLIS_IN_WEEK; static final TimeZone GMT_TIMEZONE; static final LazyObj<TimeZone> ADE_TIMEZONE; }
@Test public void testMillisecondsToHumanTimePeriodLessThanHalfOfMillisecondsInSec(){ Long period = 10000L; assertEquals("Period of time % Milliseconds in a second < 500L","00:00:10 (hh:mm:ss)",DateTimeUtils.millisecondsToHumanTime(period)); }
@Test public void testMillisecondsToHumanTimePeriodMoreThanHalfOfMillisecondsInSec(){ Long period = 500L; assertEquals("Period of time time % Milliseconds in a second >= 500L","00:00:01 (hh:mm:ss)",DateTimeUtils.millisecondsToHumanTime(period)); }