Java Second Get currentTimeSecond()

Here you can find the source of currentTimeSecond()

Description

Gets the current time, rounded down to the closest second.

License

Open Source License

Return

the current time, rounded to the closest second.

Declaration

public static long currentTimeSecond() 

Method Source Code

//package com.java2s;

public class Main {
    /** One second: 1000 milliseconds. */
    public static final long SECOND = 1000l;

    /**//from w w  w  .j a v a 2  s . co  m
     * Gets the current time, rounded down to the closest second.
     * Equivalent to invoking
     * {@code roundToSecond(System.currentTimeMillis())}.
     *
     * @return the current time, rounded to the closest second.
     */
    public static long currentTimeSecond() {
        return roundToSecond(System.currentTimeMillis());
    }

    /**
     * Rounds the given time down to the closest second.
     *
     * @param pTime time
     * @return the time rounded to the closest second.
     */
    public static long roundToSecond(final long pTime) {
        return (pTime / SECOND) * SECOND;
    }
}

Related

  1. currentTimeAsSeconds()
  2. currentTimeInSeconds()
  3. currentTimePlusNSeconds(long n)
  4. currentTimeSecond()
  5. currentTimeSeconds()
  6. currentTimeSeconds()
  7. currentTimeSeconds()
  8. getClockSkewInSeconds()