Java TimeUnit Usage getOceanTime(final Date date)

Here you can find the source of getOceanTime(final Date date)

Description

Convert the specified date to an Ocean time.

License

Open Source License

Parameter

Parameter Description
date the Date to convert.

Return

The specified date as the number of seconds since 1980.

Declaration

public static int getOceanTime(final Date date) 

Method Source Code

//package com.java2s;
/*/*ww  w  .ja  v  a 2s.c om*/
 * Telsis Limited jOCP library
 *
 * Copyright (C) Telsis Ltd. 2011-2013.
 *
 * This Program is free software: you can copy, redistribute and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License or (at your option) any later version.
 *
 * If you modify this Program you must mark it as changed by you and give a relevant date.
 *
 * This Program is published 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
 * receive a copy of the GNU General Public License along with this program. If not,
 * see <http//www.gnu.org/licenses/>.
 *
 * In making commercial use of this Program you indemnify Telsis Limited and all of its related
 * Companies for any contractual assumptions of liability that may be imposed on Telsis Limited
 * or any of its related Companies.
 *
 */

import java.util.Date;
import java.util.concurrent.TimeUnit;

public class Main {
    /** The number of seconds between 1970 and 1980. */
    public static final int NO_SECONDS_1970_1980 = 315532800;

    /**
     * Convert the current time to an Ocean time.
     *
     * @return The current time as the number of seconds since 1980.
     */
    public static int getOceanTime() {
        return getOceanTime(new Date());
    }

    /**
     * Convert the specified date to an Ocean time.
     *
     * @param date
     *            the Date to convert.
     * @return The specified date as the number of seconds since 1980.
     */
    public static int getOceanTime(final Date date) {
        return (int) TimeUnit.SECONDS.convert(date.getTime(), TimeUnit.MILLISECONDS) - NO_SECONDS_1970_1980;
    }
}

Related

  1. getMinutes(final long milliseconds)
  2. getMinutesBetweenDates(Date begin_date, Date end_date)
  3. getMinutesBetweenDates(Date firstDate, Date secondDate)
  4. getNormalizedIntervalStartTimestamp(long intervalLengthMillis, long currentTimestamp)
  5. getNowInSeconds()
  6. getPrettyTime(long duration)
  7. getQuantilesString(final Map quantilesValues)
  8. getRandomDate()
  9. getReadableElapsedIntervalInSeconds(final long elapsedTimInMillis)