Java Second Get getSecond(long time)

Here you can find the source of getSecond(long time)

Description

Gets the second.

License

Open Source License

Parameter

Parameter Description
time the time

Return

the second

Declaration

public static int getSecond(long time) 

Method Source Code

//package com.java2s;
/***// w w  w . j ava 2s  . co  m
 * Mages: Multiplayer Game Engine for mobile devices
 * Copyright (C) 2008 aksonov
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This library is distributed 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * Contact: aksonov dot gmail dot com
 *
 * Author: Pavlo Aksonov
 */

public class Main {
    /**
     * Gets the second.
     * 
     * @param time the time
     * 
     * @return the second
     */
    public static int getSecond(long time) {
        return (int) ((time - getTime(getHour(time), getMinute(time), 0)) / 1000);
    }

    /**
     * Gets the time.
     * 
     * @param hour the hour
     * @param minute the minute
     * 
     * @return the time
     */
    public static int getTime(int hour, int minute) {
        return getTime(hour, minute, 0);
    }

    /**
     * Gets the time.
     * 
     * @param hour the hour
     * @param minute the minute
     * @param second the second
     * 
     * @return the time
     */
    public static int getTime(int hour, int minute, int second) {
        return (hour * 60 * 60 + minute * 60 + second) * 1000;
    }

    /**
     * Gets the hour.
     * 
     * @param time the time
     * 
     * @return the hour
     */
    public static int getHour(long time) {
        return (int) (time / (60 * 60 * 1000));
    }

    /**
     * Gets the minute.
     * 
     * @param time the time
     * 
     * @return the minute
     */
    public static int getMinute(long time) {
        return (int) ((time - getTime(getHour(time), 0)) / (60 * 1000));
    }
}

Related

  1. getNiceStringForSeconds(String timeInSeconds)
  2. getNumberOfSecondsBetween(final double d1, final double d2)
  3. getRemainingSeconds(final long ms)
  4. getRoundedSeconds(long seconds, long interval)
  5. getSecond(long container)
  6. getSecond(String date)
  7. getSecondByDay(int day)
  8. getSecondByHour(int hour)
  9. getSecondByteFromInt(int num)