Back to project page HapiPodcastJ.
The source code is released under:
GNU General Public License
If you think the Android project HapiPodcastJ listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package info.xuluan.podcast.utils; //from ww w. j a va 2 s. co m import java.text.DecimalFormat; public class StrUtils { private static DecimalFormat mTimeDecimalFormat = new DecimalFormat("00"); public static String formatTime(long ms) { long s = ms / 1000; long m = s / 60; s = s % 60; long h = m / 60; m = m % 60; String m_s = mTimeDecimalFormat.format(m) + ":" + mTimeDecimalFormat.format(s); if (h > 0) { // show also hour return "" + h + ":" + m_s; } else { // Show only minute:second return m_s; } } public static String formatDownloadString(int offset, long length) { double d = 100.0 * offset / length; int status = (int) d; String str = "" + status + "% ( " + (formatLength(offset)) + " / " + (formatLength((int) length)) + " )"; return str; } public static int formatDownloadPrecent(int offset, long length) { double d = 100.0 * offset / length; int status = (int) d; return status; } public static String formatLength(int length) { length /= 1024; int i = (length % 1000); String s = ""; if (i < 10) { s = "00" + i; } else if (i < 100) { s = "0" + i; } else { s += i; } String str = "" + (length / 1000) + "," + s + " KB"; return str; } }