Java Minute Convert convertMsToMinutesAndSeconds(long ms)

Here you can find the source of convertMsToMinutesAndSeconds(long ms)

Description

Convert milliseconds to mm:ss display format Note we don't break into hours, 3900000 ms would display as 65:00 , and we dont put a zero before single digit minutes

License

Open Source License

Parameter

Parameter Description
ms a parameter

Declaration

public static String convertMsToMinutesAndSeconds(long ms) 

Method Source Code

//package com.java2s;

public class Main {
    /**// w  ww. j a v  a 2 s  . co  m
     * Convert milliseconds to mm:ss display format
     *
     * Note we don't break into hours, 3900000 ms would display as 65:00 , and we dont put a zero
     * before single digit minutes
     *
     * @param ms
     * @return
     */
    public static String convertMsToMinutesAndSeconds(long ms) {
        int seconds = (int) ((ms / 1000) % 60);
        int minutes = (int) (ms / 60000);
        String secondsStr = (seconds < 10 ? "0" : "") + seconds;
        return new String(minutes + ":" + secondsStr);
    }
}

Related

  1. convertMinuteSecond(double minute, double second)
  2. convertMinutesSecondsToMilliseconds(String offset)
  3. convertMinutesToMilliseconds(final long minutes)
  4. convertMinutesToSeconds(final long minutes)
  5. convertMinutesToSeconds(int minutesToConvert)
  6. convertOffsetToMinutesSeconds(int offset)
  7. convertOffsetToMinutesSecondsMillis(int offset)
  8. convertSecondsToHoursMinutesSeconds(int offset)
  9. convertSecondsToMinutes(double seconds)