Here you can find the source of format(long millis)
public static String format(long millis)
//package com.java2s; /******************************************************************************* * Copyright (c) 2009, 2016 Xored Software Inc and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * /*w w w . ja va 2s . c o m*/ * Contributors: * Xored Software Inc - initial API and implementation and/or initial documentation *******************************************************************************/ import java.text.DecimalFormat; public class Main { private static DecimalFormat secondsFormat; public static String format(long millis) { int mins = 0; double secs = 0; if (millis != 0) { double time = (double) millis / 1000; mins = (int) (time / 60); secs = time - mins * 60; } StringBuilder result = new StringBuilder(); if (mins != 0) { result.append(mins); result.append(" m "); //$NON-NLS-1$ result.append((int) secs); } else { result.append(secondsFormat.format(secs)); } return result.toString(); } }