Android examples for java.util:Date Time
convert Millis To Minutes And Seconds
import android.content.Context; import android.database.Cursor; import android.util.Log; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; public class Main{ public static String convertMillisToMinutesAndSeconds(long duration) { Date date = new Date(duration); DateFormat formatter;//www.jav a 2s . c om // if the duration is over an hour add the hour format if (duration > 3600000) { formatter = new SimpleDateFormat("HH:mm:ss"); // if over 10 minutes, add the leading digit } else if (duration > 600000) { formatter = new SimpleDateFormat("mm:ss"); } else { formatter = new SimpleDateFormat("m:ss"); } return formatter.format(date); } }