Java Second to Minute secondsToMinutes(int seconds)

Here you can find the source of secondsToMinutes(int seconds)

Description

Converts seconds into minutes

License

Open Source License

Parameter

Parameter Description
seconds The number of seconds to convert

Return

A string formatted 'MM:SS'

Declaration

public static String secondsToMinutes(int seconds) 

Method Source Code

//package com.java2s;
/**/*from  ww  w.j ava 2  s .  com*/
 * Distributed as part of Fwap'a Derp UHC. A UHC plugin for Spigot 1.9
 * made by Ashrynn Macke (Flutterflies). You should have received a copy
 * of the MIT license with this code, if not please find it here:
 * https://opensource.org/licenses/MIT
 */

public class Main {
    /**
     * Converts seconds into minutes
     *
     * @param seconds The number of seconds to convert
     * @return A string formatted 'MM:SS'
     */
    public static String secondsToMinutes(int seconds) {

        //Get the number of minutes
        int ms = seconds / 60;

        //Get the number of seconds
        int ss = seconds % 60;

        String m = (ms < 10 ? "0" : "") + ms;
        String s = (ss < 10 ? "0" : "") + ss;

        return m + ":" + s;
    }
}

Related

  1. secondsToHoursMinutesSeconds(final long secs)
  2. secondsToMinutes(int s)
  3. secondsToMinutes(int seconds)
  4. secondsToMinutes(int time)
  5. timeToMinute(String time)
  6. timeToMinutes(String in)