Here you can find the source of getSecond(long time)
Parameter | Description |
---|---|
time | the time |
public static int getSecond(long time)
//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)); } }