Java Second Convert toSecondsPrecisionInMs(long ms)

Here you can find the source of toSecondsPrecisionInMs(long ms)

Description

Reduces the precision of a time in milliseconds to seconds precision.

License

Open Source License

Parameter

Parameter Description
ms time that needs to be parsed

Return

milliseconds with seconds precision (last three digits 000).

Declaration

public static long toSecondsPrecisionInMs(long ms) 

Method Source Code

//package com.java2s;
/**/* w w w  .ja v  a  2 s  .  c  om*/
 * Copyright 2016 LinkedIn Corp. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 */

public class Main {
    /**
     * Reduces the precision of a time in milliseconds to seconds precision. Result returned is in milliseconds with last
     * three digits 000. Useful for comparing times kept in milliseconds that get converted to seconds and back (as is
     * done with HTTP date format).
     *
     * @param ms time that needs to be parsed
     * @return milliseconds with seconds precision (last three digits 000).
     */
    public static long toSecondsPrecisionInMs(long ms) {
        return ms - (ms % 1000);
    }
}

Related

  1. toSeconds(long date)
  2. toSeconds(long millis)
  3. toSeconds(long milliseconds)
  4. toSeconds(long nanoseconds)
  5. toSeconds(long nanoSeconds)
  6. toTimeStringNoSeconds(Date timeString)
  7. unixtimeToString(long unixSeconds)