Java Nano Second Convert nanoSecondToSecond(double nano, int decimal)

Here you can find the source of nanoSecondToSecond(double nano, int decimal)

Description

Convert from nano second to second

License

Open Source License

Parameter

Parameter Description
nano a parameter
decimal - decimal place precision

Declaration

public static double nanoSecondToSecond(double nano, int decimal) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from w  w  w.  j  a va  2 s. c  o m*/
     * Convert from nano second to second
     * @param nano
     * @param decimal - decimal place precision
     * @return
     */
    public static double nanoSecondToSecond(double nano, int decimal) {
        double precision = Math.pow(10, decimal);
        double second = nano / 1_000_000_000d;

        return Math.round(second * precision) / precision;
    }
}

Related

  1. nano2milli(double nano)
  2. nanoSeconds(long millis)
  3. nanoSecondsToSeconds(final long nanoSeconds)
  4. nanosecondsToSeconds(Long nanoseconds)
  5. nanosecondsToString(long ns)
  6. nanoSecToString(final long nS)
  7. nanosForFractionalValue(int value, int width)
  8. nanoTime()
  9. nanoTime()