I am making a timer for my program but I can't seem to figure out how to get it to replace the display in the output each time it counts up. So in output if it went up from 1 to 2 it would replace the 1 with two instead of having it like system.out.print would print it as 1 2 or the 2 next to the 1. I have tried using \r but that just created a new line and \b put weird symbols in my code. Any suggestions?
Here is my code, I would like the system.out to replace itself in the same spot, if it's not possible with doing it my command prompt please give other ways I could achieve my outcome
static void counter(){
int delay = 0; // delay for however long
int period = 1000; // repeat every sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
public void run()
{
SEC++;
if (SEC==60){
SEC = 0;
MINUTE++;
}
if (MINUTE==60){
MINUTE = 0;
HOUR++;
}
System.out.print(HOUR + ":" + MINUTE + ":" + SEC);
}
}, delay, period);
}