0

I am building a clock and it works mostly; The issue with my code is that I cant figure out how to have one constantly changing text instead of a billion texts with only the newly created text with the correct time

could someone please tell me how to change erase and or update this so it will fix my problem pls

import java.util.Date;
import java.text.SimpleDateFormat;

public class abugnoisyclockmainclass {
    public static void telltime () {
       for(;;) {
           Date computertime= new Date();
           SimpleDateFormat time = new SimpleDateFormat("E M-d-y        h:m:s a ");
           System.out.println(time.format(computertime));
       }
    }

    public static void main(String[] args) {
        abugnoisyclockmainclass.telltime();
    }
}
Java Devil
  • 10,629
  • 7
  • 33
  • 48
fuzzyfish
  • 15
  • 5
  • unclear what you are asking. are you meaning that you want to update a console without each date being on a separate line? – Scary Wombat May 14 '18 at 02:48
  • See if this fixes your problem https://stackoverflow.com/questions/7939802/how-can-i-print-to-the-same-line – user1762507 May 14 '18 at 03:02
  • You should also look into `ScheduledExecutorService` to run at a fixed rate of 1 second. It is excessive to create a for loop like that. – Ian Mc May 14 '18 at 03:04

0 Answers0