mercredi 6 janvier 2021

How to make a if statement with localtime.now and a set time

LocalTime settime = LocalTime.of(19, 15, 9);
        System.out.println(settime);
        for(int i = 1; i < 80; i++){
        if (LocalTime.now() == settime){
            System.out.println("IT WORKS");
        }
        else {
          //  TimeUnit.SECONDS.sleep(1);
         //System.out.println("1 ");
         i -= 1;
        }
    }

That is the code I am running The if statement is running however whenever it equals the time it does not run other than that the else statement seems to run.

Aucun commentaire:

Enregistrer un commentaire