Here you can find the source of convertMilisecondsToDisplay(Integer milliseconds, int fps)
Parameter | Description |
---|---|
miliseconds | the number of miliseconds |
fps | the number of fps |
public static String convertMilisecondsToDisplay(Integer milliseconds, int fps)
//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; } }