Here you can find the source of secondsToTime(int seconds)
Parameter | Description |
---|---|
seconds | Seconds to parse |
public static String secondsToTime(int seconds)
//package com.java2s; /*//from w w w. j a va 2 s . c o m * Util.java * * PrisonMine * Copyright (C) 2013 bitWolfy <http://www.wolvencraft.com> and contributors * * This program is free software: you can redistribute it 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. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Parses the seconds and returns time in HOUR:MIN:SEC format * @param seconds Seconds to parse * @return Time in user-friendly format */ public static String secondsToTime(int seconds) { int hour = (int) Math.floor(seconds / 3600); int min = (int) Math.floor((seconds - (hour * 3600)) / 60); int sec = seconds - (hour * 3600) - (min * 60); String resetTime = min + ":"; if (min < 10) resetTime = "0" + resetTime; resetTime = hour + ":" + resetTime; if (sec < 10) resetTime = resetTime + "0"; resetTime = resetTime + sec; return resetTime; } }