Java Nanosecond to Milliseconds nanosToMillis(final long nanos)

Here you can find the source of nanosToMillis(final long nanos)

Description

Converts the provided number of nanoseconds to milliseconds.

License

Open Source License

Parameter

Parameter Description
nanos The number of nanoseconds to convert to milliseconds.

Return

The number of milliseconds that most closely corresponds to the specified number of nanoseconds.

Declaration

public static long nanosToMillis(final long nanos) 

Method Source Code

//package com.java2s;
/*//ww  w  . j av  a 2  s .  c o m
 * Copyright (C) 2008-2018 Ping Identity Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License (GPLv2 only)
 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 */

public class Main {
    /**
     * Converts the provided number of nanoseconds to milliseconds.
     *
     * @param  nanos  The number of nanoseconds to convert to milliseconds.
     *
     * @return  The number of milliseconds that most closely corresponds to the
     *          specified number of nanoseconds.
     */
    public static long nanosToMillis(final long nanos) {
        return Math.max(0L, Math.round(nanos / 1_000_000.0d));
    }
}

Related

  1. nanosToMillis(long l)
  2. nanosToMillis(long nanos)
  3. nanosToMillisFloat(final long currentGuiTime)
  4. nanoToMillis(double nanos)