Here you can find the source of format_mm_ss(final long time)
public static String format_mm_ss(final long time)
//package com.java2s; /******************************************************************************* * Copyright (C) 2005, 2015 Wolfgang Schramm and Contributors * //from w w w. j av a 2 s . c o m * 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 version 2 of the License. * * 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, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *******************************************************************************/ import java.util.Formatter; public class Main { private static final String SYMBOL_DASH = "-"; private static final String FORMAT_MM_SS = "%d:%02d"; private static StringBuilder _sbFormatter = new StringBuilder(); private static Formatter _formatter = new Formatter(_sbFormatter); public static String format_mm_ss(final long time) { _sbFormatter.setLength(0); if (time < 0) { _sbFormatter.append(SYMBOL_DASH); } final long timeAbsolute = time < 0 ? 0 - time : time; return _formatter.format(FORMAT_MM_SS, // (timeAbsolute / 60), (timeAbsolute % 60)).toString(); } }