Android examples for java.util:Date Convert
format Long To Time String
import android.annotation.SuppressLint; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main{ public static String formatLongToTimeStr(Long l) { String str = ""; int hour = 0; int minute = 0; int second = 0; second = l.intValue() / 1000;/*w ww .j ava 2 s .co m*/ if (second > 60) { minute = second / 60; second = second % 60; } if (minute > 60) { hour = minute / 60; minute = minute % 60; } String strtime = ""; if (hour != 0) { strtime = hour + ":" + minute + ":" + second; } else { strtime = minute + ":" + (second >= 10 ? second : "0" + second); } return strtime; } }