Java Millisecond Convert millisToTime(float millis)

Here you can find the source of millisToTime(float millis)

Description

millis To Time

License

Open Source License

Declaration

public static String millisToTime(float millis) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String millisToTime(float millis) {
        float secs = millis / 1000;
        int mins = (int) (secs / 60);
        secs -= mins * 60;//from   w ww.  jav a 2s .  c  om
        secs = roundToAccuracy(secs, 0.1F);
        String time = mins + ":" + secs;
        if (time.length() > time.lastIndexOf('.') + 2) { // has excess zeros
            time = time.substring(0, time.lastIndexOf('.') + 2);
        }
        return time;
    }

    private static float roundToAccuracy(float n, float i) {
        int cutoffN = (int) (n / i);
        return cutoffN * i;
    }
}

Related

  1. millisToString(long ms)
  2. millisToString(long t)
  3. millisToStringDouble(double millis)
  4. millisToText(long millis)
  5. millisToTime(final long time)
  6. millisToTime(long ms)
  7. millisToTimeSpan(final long interv)
  8. millisToTimeSpan(long millis)
  9. MillisToTimeString(long millis)