public static String nanoSecToString(long nS){
  long rem_nS=(long)(nS % 1000.0);
  long rem_uS=(long)((nS / 1000.0) % 1000.0);
  long rem_mS=(long)((nS / 1000000.0) % 1000.0);
  long sec=(long)(nS / 1000000000.0);
  String nSstr=zeroPad(Long.toString(rem_nS),3);
  String uSstr=zeroPad(Long.toString(rem_uS),3);
  String mSstr=zeroPad(Long.toString(rem_mS),3);
  return String.format("%d.%3s %3s %3s",sec,mSstr,uSstr,nSstr);
}

public static String nanoSecToString ( long nS ) { long rem_nS = ( long ) ( nS % 1000.0 ) ; long rem_uS = ( long ) ( ( nS / 1000.0 ) % 1000.0 ) ; long rem_mS = ( long ) ( ( nS / 1000000.0 ) % 1000.0 ) ; long sec = ( long ) ( nS / 1000000000.0 ) ; String nSstr = zeroPad ( Long . toString ( rem_nS ) , 3 ) ; String uSstr = zeroPad ( Long . toString ( rem_uS ) , 3 ) ; String mSstr = zeroPad ( Long . toString ( rem_mS ) , 3 ) ; return String . format ( "%d.%3s %3s %3s" , sec , mSstr , uSstr , nSstr ) ; }
returns the given time in nanoseconds formatted as sec . msec usec nsec
