Conversion Of Nanoseconds To Milliseconds And Nanoseconds < 999999 In Java
Answer : Why not use the built in Java methods. The TimeUnit is part of the concurrent package so built exactly for you needs long durationInMs = TimeUnit.MILLISECONDS.convert(delayNS, TimeUnit.NANOSECONDS); For an ever shorter conversion using java.util.concurrent.TimeUnit , equivalent to what Shawn wrote above, you can use: long durationInMs = TimeUnit.NANOSECONDS.toMillis(delayNS); Just take the divmod of it with 1000000.