Java TimeUnit Usage getCurrentTimestampInSeconds()

Here you can find the source of getCurrentTimestampInSeconds()

Description

Get current time in seconds.

License

Open Source License

Return

the difference, measured in seconds, between the current time and midnight, January 1, 1970 UTC.

Declaration

public static long getCurrentTimestampInSeconds() 

Method Source Code


//package com.java2s;
/*/*from   w ww .j a  va 2s . c om*/
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

import java.util.concurrent.TimeUnit;

public class Main {
    /**
     * Get current time in seconds. See also {@link System#currentTimeMillis()}.
     *
     * @return the difference, measured in seconds, between the current time and midnight, January 1, 1970 UTC.
     */
    public static long getCurrentTimestampInSeconds() {
        return TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());
    }
}

Related

  1. getAllDaysCount(final long milliseconds)
  2. getBookingDays(Calendar start, Calendar end)
  3. getCurrentDateTime(int offsetMin)
  4. getCurrentTimeMillis()
  5. getCurrentTimestamp()
  6. getDate(final int oceanTime)
  7. getDateBefore(final Date day)
  8. getDateWithoutTime(final Calendar calendar)
  9. getDayFromTimestamp(final long unixTimestamp)