Java Second Convert convertMilisecondsToDisplay(Integer milliseconds, int fps)

Here you can find the source of convertMilisecondsToDisplay(Integer milliseconds, int fps)

Description

Convert miliseconds to display (00:00:00:00)

License

Open Source License

Parameter

Parameter Description
miliseconds the number of miliseconds
fps the number of fps

Return

the formated string

Declaration

public static String convertMilisecondsToDisplay(Integer milliseconds, int fps) 

Method Source Code

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

public class Main {
    /**// w w  w .j  a va  2s .c o m
     * Convert miliseconds to display (00:00:00:00)
     * 
     * @param miliseconds
     *          the number of miliseconds
     * @param fps
     *          the number of fps
     * @return the formated string
     */
    public static String convertMilisecondsToDisplay(Integer milliseconds, int fps) {
        String retObj = "";

        int hour = (int) ((milliseconds / (1000 * 60 * 60)) % 24);
        int minutes = ((milliseconds / (1000 * 60)) % 60);
        int seconds = (int) (milliseconds / 1000) % 60;
        int frames = convertMilisecondsRemainderToFrames(milliseconds, fps);
        retObj += hour < 10 ? "0" + hour : hour;
        retObj += ":" + (minutes < 10 ? "0" + minutes : minutes);
        retObj += ":" + (seconds < 10 ? "0" + seconds : seconds);
        retObj += ":" + (frames < 10 ? "0" + frames : frames);

        return retObj;
    }

    /**
     * Convert frames to miliseconds.
     * 
     * @param timeInFrames
     * @param fps
     * @return
     */
    public static int convertMilisecondsRemainderToFrames(Integer miliseconds, int fps) {
        int retObj = 0;

        if (miliseconds != null) {
            retObj = (miliseconds % 1000) / (1000 / fps);
        }

        return retObj;
    }
}

Related

  1. convertDaysInMiliseconds(long lDays)
  2. convertMilisecondsRemainderToFrames(Integer miliseconds, int fps)
  3. convertMsToFloatSeconds(final long timeMs)
  4. convertSeconds(String sStartSeconds, String sEndSeconds)
  5. convertSecondsToDays(double secs)
  6. convertSecondsToMiliseconds(double seconds)