Here you can find the source of toTime(int duration)
private static String toTime(int duration)
//package com.java2s; /******************************************************************************* * Copyright (C) 2014 Travis Ralston (turt2live) * * This software 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.1 of the License, or (at your option) any later version. * * This software 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 software; If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ public class Main { private static String toTime(int duration) { double asMinutes = ((double) duration) / 60.0; int minutes = (int) Math.floor(asMinutes); int seconds = duration - (minutes * 60); return minutes + ":" + ((seconds + "").length() < 2 ? "0" + seconds : seconds); }//from w w w . j a v a2 s. c om }