I have a countdown timer that I have created (before you suggest the built in one, I have unsolved problems with that in the past). Clearly I'm just not formatting this correctly, but I just can't seem to get it to go "mm:ss" for my data. Instead I get "mmmmmmm:ss". Where did I go wrong?
TimerTask mTimerTask;
final Handler handler = new Handler();
Timer t = new Timer();
private long nCounter = 180000;
int minutes;
int seconds;
public void doTimerTask(){
mTimerTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
if(nCounter<=0){
stopTask();
return;
}
nCounter--;
// seconds = (int) ((nCounter / 1000) % 60);
// minutes = (int) ((nCounter / 1000) / 60);
seconds = (int)(nCounter) % 60 ;
minutes = (int)((nCounter-seconds)/60);
// update TextView
timerTextView.setText(String.format("%d:%02d", minutes, seconds));
}
});
}};
// public void schedule (TimerTask task, long delay, long period)
t.scheduleAtFixedRate(mTimerTask,0,1000);
}