Here you can find the source of MillisToTimeString(long millis)
public static String MillisToTimeString(long millis)
//package com.java2s; //License from project: Apache License public class Main { public static String MillisToTimeString(long millis) { int hours, minutes, seconds; float timeValue = millis / 3600000.0f; hours = (int) Math.floor(timeValue); minutes = (int) Math.floor((timeValue - hours) * 60); seconds = (int) Math.round((timeValue - hours - (minutes / 60.0f)) * 3600); if (seconds >= 60) { seconds -= 60;/*from ww w . j av a 2 s.c o m*/ minutes += 1; } if (minutes >= 60) { minutes -= 60; hours += 1; } String formattedFreq = ""; if (hours != 0) { formattedFreq = String.valueOf(hours) + ":"; } formattedFreq += String.format("%02d:%02d", minutes, seconds); return formattedFreq; } }