Java Second Get getSecondsToMMSS(double seconds)

Here you can find the source of getSecondsToMMSS(double seconds)

Description

get Seconds To MMSS

License

Open Source License

Declaration

public static String getSecondsToMMSS(double seconds) 

Method Source Code

//package com.java2s;
/*/* w  ww  .j ava  2s.  c  om*/
 * Copyright (C) 2012-2015, Juan Manuel Barrios <http://juan.cl/>
 * All rights reserved.
 *
 * This file is part of P-VCD. http://p-vcd.org/
 * P-VCD is made available under the terms of the BSD 2-Clause License.
 */

public class Main {
    public static String getSecondsToMMSS(double seconds) {
        long seg = (int) Math.round(seconds);
        if (seg >= 3600)
            return getSecondsToHHMMSS(seconds);
        long mm = seg / 60;
        seg = seg % 60;
        return (mm < 10 ? "0" : "") + mm + ":" + (seg < 10 ? "0" : "") + seg;
    }

    public static String getSecondsToHHMMSS(double seconds) {
        long seg = Math.round(seconds);
        long hh = seg / 3600;
        seg = seg % 3600;
        long mm = seg / 60;
        seg = seg % 60;
        return (hh < 10 ? "0" : "") + hh + ":" + (mm < 10 ? "0" : "") + mm + ":" + (seg < 10 ? "0" : "") + seg;
    }
}

Related

  1. getSecondsFromStringDuration(String duration)
  2. getSecondSimpleType(String completeType)
  3. getSecondsInDDHHMMSS(int s)
  4. getSecondsText(long seconds)
  5. getSecondsToHHMMSS(double seconds)
  6. getSecondTime()
  7. getSecondTime(String time)
  8. getSecondToLastIndexOf(String string, char character)
  9. getSecondVersion(String buildId)