@Test public void should() { assertEquals(1, Utils.nanosToMillis(1000000)); assertEquals(-1, Utils.nanosToMillis(-1000000)); assertEquals(1, Utils.nanosToMillis(1499999)); assertEquals(-1, Utils.nanosToMillis(-1499999)); assertEquals(2, Utils.nanosToMillis(1500000)); assertEquals(-1, Utils.nanosToMillis(-1500000)); assertEquals(0, Utils.nanosToMillis(499999)); assertEquals(0, Utils.nanosToMillis(-500000)); assertEquals(1, Utils.nanosToMillis(500000)); assertEquals(-1, Utils.nanosToMillis(-500001)); assertEquals(1, Utils.nanosToMillis(999999)); assertEquals(-1, Utils.nanosToMillis(-999999)); }
public static long nanosToMillis(long l) { return Math.round(((double) l) / nanosInMillisecond); }
Utils { public static long nanosToMillis(long l) { return Math.round(((double) l) / nanosInMillisecond); } }
Utils { public static long nanosToMillis(long l) { return Math.round(((double) l) / nanosInMillisecond); } private  Utils(); }
Utils { public static long nanosToMillis(long l) { return Math.round(((double) l) / nanosInMillisecond); } private  Utils(); static String indent(String s); static String format(Date d); static String formatTime(Date d); static PreparedStatement safelyPrepareStatement(MonitorRunLogPrefix curRunLogPrefix, Connection c, String dsDesc, int sqlExecTimeout, String sql); static long nanosToMillis(long l); static long roundMillisWithSecondPrecision(long l); static String nanosToMillisAsStr(long l); static String assertNonEmpty(String s, String name); static void assertNotNull(Object field, String fieldName); static void assertNull(Object field, String fieldName); static void assertSame(Object o1, Object o2, String msg); static void assertNonNegative(int field, String fieldName); static void assertNonNegative(long field, String fieldName); static void assertPositive(int field, String fieldName); static long millisToNanos(int i); static void assertNonZero(int i, String fieldName); }
Utils { public static long nanosToMillis(long l) { return Math.round(((double) l) / nanosInMillisecond); } private  Utils(); static String indent(String s); static String format(Date d); static String formatTime(Date d); static PreparedStatement safelyPrepareStatement(MonitorRunLogPrefix curRunLogPrefix, Connection c, String dsDesc, int sqlExecTimeout, String sql); static long nanosToMillis(long l); static long roundMillisWithSecondPrecision(long l); static String nanosToMillisAsStr(long l); static String assertNonEmpty(String s, String name); static void assertNotNull(Object field, String fieldName); static void assertNull(Object field, String fieldName); static void assertSame(Object o1, Object o2, String msg); static void assertNonNegative(int field, String fieldName); static void assertNonNegative(long field, String fieldName); static void assertPositive(int field, String fieldName); static long millisToNanos(int i); static void assertNonZero(int i, String fieldName); static final DateFormat df; static final DateFormat tf; }