DatetimeHelper { public static String convertSecondsToReadableDuration(long totalMilliseconds) { if (totalMilliseconds < 0) { return " < 1 min"; } long totalSeconds = totalMilliseconds / 1000; long totalMinutes = totalSeconds / SECONDS_IN_A_MINUTE; long minutes = totalMinutes % MINUTES_IN_AN_HOUR; long hours = totalMinutes / MINUTES_IN_AN_HOUR; StringBuilder durationStr = new StringBuilder(); if (hours > 0) { durationStr.append(hours).append(" hr "); } if (hours < 1 && minutes < 1) { durationStr.append(" < 1 min"); } else { durationStr.append(minutes).append(" min"); } return durationStr.toString(); }  static long getTimestamp(); static String dateToString(Date date); static Date stringToDate(String dateText); static String dateToShortReadableString(Context context, Date date); static String convertSecondsToReadableDuration(long totalMilliseconds); static String convertSecondsToDuration(long totalMilliseconds); static String formatRFC822Date(Date date);  }
@Test public void convertSecondsToReadableDurationTest() { assertEquals(" < 1m", DatetimeHelper.convertSecondsToReadableDuration(-1_000)); assertEquals(" < 1m", DatetimeHelper.convertSecondsToReadableDuration(1_000)); assertEquals("5m", DatetimeHelper.convertSecondsToReadableDuration(300_000)); assertEquals("10m", DatetimeHelper.convertSecondsToReadableDuration(600_000)); assertEquals("1h 0m", DatetimeHelper.convertSecondsToReadableDuration(3_600_000)); assertEquals("1h 0m", DatetimeHelper.convertSecondsToReadableDuration(3_620_000)); }