@Test public void testFormatTime() { Assert.assertEquals(PlotDataCursor.formatTime(PlotConstants.MILLISECONDS_IN_SECOND), "+0/00:00:01" ); Assert.assertEquals(PlotDataCursor.formatTime(PlotConstants.MILLISECONDS_IN_MIN), "+0/00:01:00" ); Assert.assertEquals(PlotDataCursor.formatTime(PlotConstants.MILLISECONDS_IN_HOUR), "+0/01:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(PlotConstants.MILLISECONDS_IN_DAY), "+1/00:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(-PlotConstants.MILLISECONDS_IN_SECOND), "-0/00:00:01" ); Assert.assertEquals(PlotDataCursor.formatTime(-PlotConstants.MILLISECONDS_IN_MIN), "-0/00:01:00" ); Assert.assertEquals(PlotDataCursor.formatTime(-PlotConstants.MILLISECONDS_IN_HOUR), "-0/01:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(-PlotConstants.MILLISECONDS_IN_DAY), "-1/00:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * PlotConstants.MILLISECONDS_IN_SECOND), "+0/00:00:10" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * PlotConstants.MILLISECONDS_IN_MIN), "+0/00:10:00" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * PlotConstants.MILLISECONDS_IN_HOUR), "+0/10:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * PlotConstants.MILLISECONDS_IN_DAY), "+10/00:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * -PlotConstants.MILLISECONDS_IN_SECOND), "-0/00:00:10" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * -PlotConstants.MILLISECONDS_IN_MIN), "-0/00:10:00" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * -PlotConstants.MILLISECONDS_IN_HOUR), "-0/10:00:00" ); Assert.assertEquals(PlotDataCursor.formatTime(10 * -PlotConstants.MILLISECONDS_IN_DAY), "-10/00:00:00" ); long oneDayOneHourOneMinOneSecond = PlotConstants.MILLISECONDS_IN_DAY + PlotConstants.MILLISECONDS_IN_HOUR + PlotConstants.MILLISECONDS_IN_MIN + PlotConstants.MILLISECONDS_IN_SECOND; Assert.assertEquals(PlotDataCursor.formatTime(oneDayOneHourOneMinOneSecond), "+1/01:01:01" ); long tenDaytenHourTenMinTenSecond = 10 * PlotConstants.MILLISECONDS_IN_DAY + 10 * PlotConstants.MILLISECONDS_IN_HOUR + 10 * PlotConstants.MILLISECONDS_IN_MIN + 10 * PlotConstants.MILLISECONDS_IN_SECOND; Assert.assertEquals(PlotDataCursor.formatTime(tenDaytenHourTenMinTenSecond), "+10/10:10:10" ); }
static String formatTime(long timeDelta) { String sign = "+"; if (timeDelta < 0) { sign = "-"; timeDelta = timeDelta * -1; } StringBuilder timeString = new StringBuilder(); long days = timeDelta / PlotConstants.MILLISECONDS_IN_DAY; long remainder = timeDelta % PlotConstants.MILLISECONDS_IN_DAY; long hours = remainder / PlotConstants.MILLISECONDS_IN_HOUR; remainder = remainder % PlotConstants.MILLISECONDS_IN_HOUR; long mins = remainder / PlotConstants.MILLISECONDS_IN_MIN; remainder = remainder % PlotConstants.MILLISECONDS_IN_MIN; long seconds = remainder / PlotConstants.MILLISECONDS_IN_SECOND; remainder = remainder % PlotConstants.MILLISECONDS_IN_SECOND; timeString.append(sign); timeString.append(days); timeString.append("/"); if (hours < 10) { timeString.append("0"); } timeString.append(hours); timeString.append(":"); if (mins < 10) { timeString.append("0"); } timeString.append(mins); timeString.append(":"); if (seconds < 10) { timeString.append("0"); } timeString.append(seconds); return timeString.toString(); }
PlotDataCursor { static String formatTime(long timeDelta) { String sign = "+"; if (timeDelta < 0) { sign = "-"; timeDelta = timeDelta * -1; } StringBuilder timeString = new StringBuilder(); long days = timeDelta / PlotConstants.MILLISECONDS_IN_DAY; long remainder = timeDelta % PlotConstants.MILLISECONDS_IN_DAY; long hours = remainder / PlotConstants.MILLISECONDS_IN_HOUR; remainder = remainder % PlotConstants.MILLISECONDS_IN_HOUR; long mins = remainder / PlotConstants.MILLISECONDS_IN_MIN; remainder = remainder % PlotConstants.MILLISECONDS_IN_MIN; long seconds = remainder / PlotConstants.MILLISECONDS_IN_SECOND; remainder = remainder % PlotConstants.MILLISECONDS_IN_SECOND; timeString.append(sign); timeString.append(days); timeString.append("/"); if (hours < 10) { timeString.append("0"); } timeString.append(hours); timeString.append(":"); if (mins < 10) { timeString.append("0"); } timeString.append(mins); timeString.append(":"); if (seconds < 10) { timeString.append("0"); } timeString.append(seconds); return timeString.toString(); } }
PlotDataCursor { static String formatTime(long timeDelta) { String sign = "+"; if (timeDelta < 0) { sign = "-"; timeDelta = timeDelta * -1; } StringBuilder timeString = new StringBuilder(); long days = timeDelta / PlotConstants.MILLISECONDS_IN_DAY; long remainder = timeDelta % PlotConstants.MILLISECONDS_IN_DAY; long hours = remainder / PlotConstants.MILLISECONDS_IN_HOUR; remainder = remainder % PlotConstants.MILLISECONDS_IN_HOUR; long mins = remainder / PlotConstants.MILLISECONDS_IN_MIN; remainder = remainder % PlotConstants.MILLISECONDS_IN_MIN; long seconds = remainder / PlotConstants.MILLISECONDS_IN_SECOND; remainder = remainder % PlotConstants.MILLISECONDS_IN_SECOND; timeString.append(sign); timeString.append(days); timeString.append("/"); if (hours < 10) { timeString.append("0"); } timeString.append(hours); timeString.append(":"); if (mins < 10) { timeString.append("0"); } timeString.append(mins); timeString.append(":"); if (seconds < 10) { timeString.append("0"); } timeString.append(seconds); return timeString.toString(); } PlotDataCursor(PlotterPlot plot); }
PlotDataCursor { static String formatTime(long timeDelta) { String sign = "+"; if (timeDelta < 0) { sign = "-"; timeDelta = timeDelta * -1; } StringBuilder timeString = new StringBuilder(); long days = timeDelta / PlotConstants.MILLISECONDS_IN_DAY; long remainder = timeDelta % PlotConstants.MILLISECONDS_IN_DAY; long hours = remainder / PlotConstants.MILLISECONDS_IN_HOUR; remainder = remainder % PlotConstants.MILLISECONDS_IN_HOUR; long mins = remainder / PlotConstants.MILLISECONDS_IN_MIN; remainder = remainder % PlotConstants.MILLISECONDS_IN_MIN; long seconds = remainder / PlotConstants.MILLISECONDS_IN_SECOND; remainder = remainder % PlotConstants.MILLISECONDS_IN_SECOND; timeString.append(sign); timeString.append(days); timeString.append("/"); if (hours < 10) { timeString.append("0"); } timeString.append(hours); timeString.append(":"); if (mins < 10) { timeString.append("0"); } timeString.append(mins); timeString.append(":"); if (seconds < 10) { timeString.append("0"); } timeString.append(seconds); return timeString.toString(); } PlotDataCursor(PlotterPlot plot); boolean isSlopeLineEnabled(); }
PlotDataCursor { static String formatTime(long timeDelta) { String sign = "+"; if (timeDelta < 0) { sign = "-"; timeDelta = timeDelta * -1; } StringBuilder timeString = new StringBuilder(); long days = timeDelta / PlotConstants.MILLISECONDS_IN_DAY; long remainder = timeDelta % PlotConstants.MILLISECONDS_IN_DAY; long hours = remainder / PlotConstants.MILLISECONDS_IN_HOUR; remainder = remainder % PlotConstants.MILLISECONDS_IN_HOUR; long mins = remainder / PlotConstants.MILLISECONDS_IN_MIN; remainder = remainder % PlotConstants.MILLISECONDS_IN_MIN; long seconds = remainder / PlotConstants.MILLISECONDS_IN_SECOND; remainder = remainder % PlotConstants.MILLISECONDS_IN_SECOND; timeString.append(sign); timeString.append(days); timeString.append("/"); if (hours < 10) { timeString.append("0"); } timeString.append(hours); timeString.append(":"); if (mins < 10) { timeString.append("0"); } timeString.append(mins); timeString.append(":"); if (seconds < 10) { timeString.append("0"); } timeString.append(seconds); return timeString.toString(); } PlotDataCursor(PlotterPlot plot); boolean isSlopeLineEnabled();  }