@Test public void createDurationValueMillisTest() { final String expected = "123 ms"; final Long duration = 123L; final Date startTime = new Date(0); final Date endTime = new Date(duration); final String durationValue = DurationHelper.createDurationValue(startTime, endTime); assertThat(durationValue).isEqualTo(expected); }
public static String createDurationValue(Date startTime, Date endTime) { final Date current = new Date(); if (startTime == null) { startTime = current; log.info("startTime was null, set to current date"); } if (endTime == null) { endTime = current; log.info("endTime was null, set to current date"); } final Long duration = endTime.getTime() - startTime.getTime() < 0 ? 0 : endTime.getTime() - startTime.getTime(); return format(new Date(duration)); }
DurationHelper { public static String createDurationValue(Date startTime, Date endTime) { final Date current = new Date(); if (startTime == null) { startTime = current; log.info("startTime was null, set to current date"); } if (endTime == null) { endTime = current; log.info("endTime was null, set to current date"); } final Long duration = endTime.getTime() - startTime.getTime() < 0 ? 0 : endTime.getTime() - startTime.getTime(); return format(new Date(duration)); } }
DurationHelper { public static String createDurationValue(Date startTime, Date endTime) { final Date current = new Date(); if (startTime == null) { startTime = current; log.info("startTime was null, set to current date"); } if (endTime == null) { endTime = current; log.info("endTime was null, set to current date"); } final Long duration = endTime.getTime() - startTime.getTime() < 0 ? 0 : endTime.getTime() - startTime.getTime(); return format(new Date(duration)); } private  DurationHelper(); }
DurationHelper { public static String createDurationValue(Date startTime, Date endTime) { final Date current = new Date(); if (startTime == null) { startTime = current; log.info("startTime was null, set to current date"); } if (endTime == null) { endTime = current; log.info("endTime was null, set to current date"); } final Long duration = endTime.getTime() - startTime.getTime() < 0 ? 0 : endTime.getTime() - startTime.getTime(); return format(new Date(duration)); } private  DurationHelper(); static String createDurationValue(Date startTime, Date endTime); }
DurationHelper { public static String createDurationValue(Date startTime, Date endTime) { final Date current = new Date(); if (startTime == null) { startTime = current; log.info("startTime was null, set to current date"); } if (endTime == null) { endTime = current; log.info("endTime was null, set to current date"); } final Long duration = endTime.getTime() - startTime.getTime() < 0 ? 0 : endTime.getTime() - startTime.getTime(); return format(new Date(duration)); } private  DurationHelper(); static String createDurationValue(Date startTime, Date endTime);  }