Here you can find the source of nanosToHMSms(long nanos)
public static String nanosToHMSms(long nanos)
//package com.java2s; import java.util.concurrent.TimeUnit; public class Main { public static String nanosToHMSms(long nanos) { long hour = TimeUnit.NANOSECONDS.toHours(nanos); long in1 = nanos - TimeUnit.HOURS.toNanos(hour); long minute = TimeUnit.NANOSECONDS.toMinutes(in1); long in2 = in1 - TimeUnit.MINUTES.toNanos(minute); long second = TimeUnit.NANOSECONDS.toSeconds(in2); long in3 = in2 - TimeUnit.SECONDS.toNanos(second); long milli = TimeUnit.NANOSECONDS.toMillis(in3); long in4 = in3 - TimeUnit.MILLISECONDS.toNanos(milli); long micro = TimeUnit.NANOSECONDS.toMicros(in4); long nano = in4 - TimeUnit.MICROSECONDS.toNanos(micro); return String.format("%dh:%dm:%ds:%dms:%dus:%sns", hour, minute, second, milli, micro, nano); }/*from w w w. j a v a 2 s . c o m*/ }