right now I have my timer displaying seconds, what can I add to it to display the time in a 0:00 format?
new CountDownTimer((300 * 1000), 1000) {
public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish() {
mTextField.setText("Session Completed!");
}
}.start();
Try this:
Date date = new Date((300 * 1000)* 1000);
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
String dateFormatted = formatter.format(date);
You can also use
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss:SSS");
@Override
public void onTick(long millisUntilFinished) {
long temp_long = millisUntilFinished / 1000;
second = temp_long % 60;
hour = temp_long / 3600;
minute = (temp_long / 60) % 60;
String tempTimer;
tempTimer = ((hour < 10) ? "0" + hour : "" + hour)+ ((minute < 10) ? ":0" + minute : ":"+ minute)+ ((second < 10) ? ":0" + second : ":" + second);
mTextField.setText(tempTimer);
}
You can use android Chronometer to display countdown.
http://developer.android.com/reference/android/widget/Chronometer.html