Here you can find the source of convertTime(Long time)
public static String convertTime(Long time)
//package com.java2s; //License from project: Apache License public class Main { public static final String TIME_FORMAT = "00:00:00"; public static String convertTime(Long time) { long timelong = time.longValue(); if (timelong == 0) { return TIME_FORMAT; }// www. j a v a 2 s. c o m if (timelong > 0) { long h = 0, hh = 0; long m = 0, mm = 0; long s = 0; h = timelong / 3600; hh = timelong % 3600; m = hh / 60; mm = hh % 60; s = mm; String hStr, mStr, sStr = ""; if (h < 10) { hStr = "0" + h; } else { hStr = "" + h; } if (m < 10) { mStr = "0" + m; } else { mStr = "" + m; } if (s < 10) { sStr = "0" + s; } else { sStr = "" + s; } // if (h > 0) { // return hStr + ":" + mStr + ":" + sStr; // } // if (h == 0 && m > 0) { // return mStr + ":" + s; // } // if (m == 0 && s > 0) { // return s + "s"; // } return hStr + ":" + mStr + ":" + sStr; } return TIME_FORMAT; } }