@Test public void testGetHumanReadableTimeStringInputHoursMinutesAndSecondsExpectsAllThreePresent() { assertEquals("1 hour 1 minute 1 second", Log.getHumanReadableTimeString(3661)); }
public static String getHumanReadableTimeString(long seconds) { String result = ""; long hours = seconds / SECONDS_IN_HOURS; if (hours == 1) { result += hours + " hour "; } else if (hours > 1) { result += hours + " hours "; } long minutes = (seconds % SECONDS_IN_HOURS) / SECONDS_IN_MINUTES; if (minutes == 1) { result += minutes + " minute "; } else if (minutes > 1) { result += minutes + " minutes "; } long remainderSeconds = (seconds % SECONDS_IN_HOURS) % SECONDS_IN_MINUTES; if (remainderSeconds == 1) { result += remainderSeconds + " second"; } else if (remainderSeconds > 1) { result += remainderSeconds + " seconds"; } result = StringUtils.trim(result); return result; }
Log { public static String getHumanReadableTimeString(long seconds) { String result = ""; long hours = seconds / SECONDS_IN_HOURS; if (hours == 1) { result += hours + " hour "; } else if (hours > 1) { result += hours + " hours "; } long minutes = (seconds % SECONDS_IN_HOURS) / SECONDS_IN_MINUTES; if (minutes == 1) { result += minutes + " minute "; } else if (minutes > 1) { result += minutes + " minutes "; } long remainderSeconds = (seconds % SECONDS_IN_HOURS) % SECONDS_IN_MINUTES; if (remainderSeconds == 1) { result += remainderSeconds + " second"; } else if (remainderSeconds > 1) { result += remainderSeconds + " seconds"; } result = StringUtils.trim(result); return result; } }
Log { public static String getHumanReadableTimeString(long seconds) { String result = ""; long hours = seconds / SECONDS_IN_HOURS; if (hours == 1) { result += hours + " hour "; } else if (hours > 1) { result += hours + " hours "; } long minutes = (seconds % SECONDS_IN_HOURS) / SECONDS_IN_MINUTES; if (minutes == 1) { result += minutes + " minute "; } else if (minutes > 1) { result += minutes + " minutes "; } long remainderSeconds = (seconds % SECONDS_IN_HOURS) % SECONDS_IN_MINUTES; if (remainderSeconds == 1) { result += remainderSeconds + " second"; } else if (remainderSeconds > 1) { result += remainderSeconds + " seconds"; } result = StringUtils.trim(result); return result; } Log(Logger logger); }
Log { public static String getHumanReadableTimeString(long seconds) { String result = ""; long hours = seconds / SECONDS_IN_HOURS; if (hours == 1) { result += hours + " hour "; } else if (hours > 1) { result += hours + " hours "; } long minutes = (seconds % SECONDS_IN_HOURS) / SECONDS_IN_MINUTES; if (minutes == 1) { result += minutes + " minute "; } else if (minutes > 1) { result += minutes + " minutes "; } long remainderSeconds = (seconds % SECONDS_IN_HOURS) % SECONDS_IN_MINUTES; if (remainderSeconds == 1) { result += remainderSeconds + " second"; } else if (remainderSeconds > 1) { result += remainderSeconds + " seconds"; } result = StringUtils.trim(result); return result; } Log(Logger logger); static Log mk(Class<?> clazz); void startUnitOfWork(); void endUnitOfWork(); void continueContext(Collection<String> init); static String getHumanReadableTimeString(long seconds); List<String> getContext(); void debug(String msg); void debug(String msg, Object... args); void info(String msg); void info(String msg, Object... args); void warn(String msg); void warn(String msg, Object... args); void warn(Throwable t, String msg); void error(String msg); void error(String msg, Object... args); void error(Throwable t, String msg, Object... args); }
Log { public static String getHumanReadableTimeString(long seconds) { String result = ""; long hours = seconds / SECONDS_IN_HOURS; if (hours == 1) { result += hours + " hour "; } else if (hours > 1) { result += hours + " hours "; } long minutes = (seconds % SECONDS_IN_HOURS) / SECONDS_IN_MINUTES; if (minutes == 1) { result += minutes + " minute "; } else if (minutes > 1) { result += minutes + " minutes "; } long remainderSeconds = (seconds % SECONDS_IN_HOURS) % SECONDS_IN_MINUTES; if (remainderSeconds == 1) { result += remainderSeconds + " second"; } else if (remainderSeconds > 1) { result += remainderSeconds + " seconds"; } result = StringUtils.trim(result); return result; } Log(Logger logger); static Log mk(Class<?> clazz); void startUnitOfWork(); void endUnitOfWork(); void continueContext(Collection<String> init); static String getHumanReadableTimeString(long seconds); List<String> getContext(); void debug(String msg); void debug(String msg, Object... args); void info(String msg); void info(String msg, Object... args); void warn(String msg); void warn(String msg, Object... args); void warn(Throwable t, String msg); void error(String msg); void error(String msg, Object... args); void error(Throwable t, String msg, Object... args);  }