Java Milliseconds roundTimeToTheNearestSecondInMilliseconds(long timeInMilliseconds)

Here you can find the source of roundTimeToTheNearestSecondInMilliseconds(long timeInMilliseconds)

Description

Round time in Milliseconds to the nearest second, and return as time in milliseconds

License

Apache License

Parameter

Parameter Description
timeInMilliseconds a parameter

Return

roundedTimeInMilliSeconds rounded to the nearest second.

Declaration

public static long roundTimeToTheNearestSecondInMilliseconds(long timeInMilliseconds) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**//from  w w w. ja va2  s.c  o m
     * Round time in Milliseconds to the nearest second, and return as time in milliseconds
     * 
     * @param timeInMilliseconds
     * @return roundedTimeInMilliSeconds rounded to the nearest second.
     */
    public static long roundTimeToTheNearestSecondInMilliseconds(long timeInMilliseconds) {
        double timeInSeconds = ((double) timeInMilliseconds) / 1000.0;
        timeInSeconds = Math.round(timeInSeconds);
        long roundedTimeInMilliseconds = (long) (timeInSeconds * 1000.0);
        return roundedTimeInMilliseconds;
    }
}

Related

  1. resetMilliseconds(long msec)
  2. reverseTimeMillis(long currentTimeMillis)
  3. rollMockClockMillis(long millis)
  4. roundMicrosToMillis(String micros)
  5. roundMillisWithSecondPrecision(long l)
  6. safeSleepMillis(long milliseconds)
  7. samples2millis(long samples, double sampleRate)
  8. samplesToMilliseconds(int sampleRate, int samples)
  9. setGlobalDebugMillis(int millis)