Here you can find the source of millisToString(long t)
public static String millisToString(long t)
//package com.java2s; /**/*from w ww . java2 s.c o m*/ * Copyright 2014-2017 Functional Genomics Development Team, European Bioinformatics Institute * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * @author Mikhail Gostev <gostev@gmail.com> **/ public class Main { public static String millisToString(long t) { StringBuilder sb = new StringBuilder(); long frac = t / 3600000L; if (frac > 0) { sb.append(frac).append("h"); t = t - frac * 3600000; } frac = t / 60000; if (frac > 0) { if (sb.length() > 0) { sb.append(' '); } sb.append(frac).append("m"); t = t - frac * 60000; } frac = t / 1000; if (frac > 0) { if (sb.length() > 0) { sb.append(' '); } sb.append(frac).append("s"); t = t - frac * 1000; } if (t > 0) { if (sb.length() > 0) { sb.append(' '); } sb.append(t).append("ms"); } return sb.toString(); } }