Java Minute Format formatSecondsToMinutes(int secontsTotal)

Here you can find the source of formatSecondsToMinutes(int secontsTotal)

Description

format Seconds To Minutes

License

Open Source License

Declaration

public static String formatSecondsToMinutes(int secontsTotal) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * The MIT License (MIT)/*  ww  w  .  java  2 s. c om*/
 * 
 * Copyright (C) 2014-2018 Sam Bassett (aka Lothrazar)
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 ******************************************************************************/

public class Main {
    public static String formatSecondsToMinutes(int secontsTotal) {
        if (secontsTotal < 0) {
            return "";
        }
        int minutes = secontsTotal / 60;
        int secs = secontsTotal % 60;
        return minutes + ":" + String.format("%02d", secs);
    }
}

Related

  1. formatMinutes(int minutes)
  2. formatMinutes(long time)
  3. formatMinutes(long time)
  4. formatMinutes(long time, String timerPrecisionId, boolean round)
  5. formatMinutes(long timeMinutes)
  6. formatTimeInMinutes(long l)
  7. getFormattedHoursAndMinutes(final long millis)
  8. toReadableMinutes(long time)