Java Formatter Usage format_mm_ss(final long time)

Here you can find the source of format_mm_ss(final long time)

Description

formamss

License

Open Source License

Declaration

public static String format_mm_ss(final long time) 

Method Source Code

//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();
    }
}

Related

  1. Fmt(String format, Object... args)
  2. format(double value)
  3. format(Locale l, String format, Object... args)
  4. format(String format, Object... args)
  5. format_hh_mm_ss_Optional(final long value)
  6. formatLong(long number, int length)
  7. formatMessageException(String format, Object... args)
  8. formatNumber(int number)
  9. formatResponse(Formatter formatter, String response)