Here you can find the source of getOceanTime(final Date date)
Parameter | Description |
---|---|
date | the Date to convert. |
public static int getOceanTime(final Date date)
//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; } }