Here you can find the source of msToString(long milliseconds)
public static String msToString(long milliseconds)
//package com.java2s; /*/*from w ww . j a v a 2s .c o m*/ * Utilities common to all types of replication (NMR) * * Copyright (c) 2008 Brigham Young University * * This file is part of the BYU EDIF Tools. * * BYU EDIF Tools is free software: you may redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 2 of the License, or (at your option) any * later version. * * BYU EDIF Tools 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. * * A copy of the GNU General Public License is included with the BYU EDIF Tools. * It can be found at /edu/byu/edif/doc/gpl2.txt. You may also get a copy of the * license at <http://www.gnu.org/licenses/>. * */ import java.text.DecimalFormat; public class Main { public static String msToString(long milliseconds) { long sec = milliseconds / 1000; long min = sec / 60; long hour = min / 60; milliseconds %= 1000; sec %= 60; min %= 60; DecimalFormat twoDigits = new DecimalFormat("00"); return new String(twoDigits.format(hour) + ":" + twoDigits.format(min) + ":" + twoDigits.format(sec) + "." + milliseconds); } }