Java Second Convert toSeconds(long nanoseconds)

Here you can find the source of toSeconds(long nanoseconds)

Description

Converts nanoseconds to seconds

License

Open Source License

Parameter

Parameter Description
nanoseconds a parameter

Declaration

public static double toSeconds(long nanoseconds) 

Method Source Code

//package com.java2s;

public class Main {
    public static final double NANOSECONDS_PER_MILLISECONDS = 1000000, MILLISECONDS_PER_SECONDS = 1000,
            SECONDS_PER_HOUR = 3600;//from  w  ww.  j a  v  a 2  s.  com

    /**
     * Converts nanoseconds to seconds
     * @param nanoseconds
     */
    public static double toSeconds(long nanoseconds) {
        return toSeconds((double) nanoseconds);
    }

    /**
     * Converts nanoseconds to seconds
     * @param nanoseconds
     */
    public static double toSeconds(double nanoseconds) {
        double ms = nanoseconds / NANOSECONDS_PER_MILLISECONDS;
        return ms / MILLISECONDS_PER_SECONDS;
    }
}

Related

  1. toSeconds(double value)
  2. toSeconds(long date)
  3. toSeconds(long millis)
  4. toSeconds(long milliseconds)
  5. toSeconds(long nanoSeconds)
  6. toSecondsPrecisionInMs(long ms)
  7. toTimeStringNoSeconds(Date timeString)
  8. unixtimeToString(long unixSeconds)