Java Second Convert secondsToString(long seconds)

Here you can find the source of secondsToString(long seconds)

Description

Converts seconds from long to a String in the format "mm:ss".

License

Apache License

Parameter

Parameter Description
seconds positive number, if negative it is multiplicated by -1

Return

String representation like "mm:ss"

Declaration

public static String secondsToString(long seconds) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*  w  ww.j a  va  2 s  . c  om*/
     * Converts seconds from long to a String in the format "mm:ss".
     *
     * @param seconds
     *           positive number, if negative it is multiplicated by -1
     * @return String representation like "mm:ss"
     */
    public static String secondsToString(long seconds) {
        if (seconds < 0) {
            seconds = seconds * -1;
        }
        return String.format("%02d:%02d", seconds / 60, seconds % 60);
    }
}

Related

  1. secondsToNanoseconds(long seconds)
  2. secondsToReadableBiggest(int seconds)
  3. secondsToString(int seconds)
  4. secondsToString(long seconds)
  5. SecondsToString(long seconds)
  6. secondsToString(long time)
  7. secondsToStringWithUnits(double value)
  8. secondsToTicks(double seconds)
  9. secondsToTicks(double x)