-
-
Save parzibyte/bdc1c92d394c586241b14cf937fcabb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No olvides importar las clases en la parte superior de tu archivo: | |
import java.time.LocalDateTime; | |
import java.time.format.DateTimeFormatter; | |
// Pon el código dentro de un método que se ejecute al inicio y una sola vez | |
DateTimeFormatter formateador = DateTimeFormatter.ofPattern("HH:mm:ss"); | |
Runnable runnable = new Runnable() { | |
@Override | |
public void run() { | |
while (true) { | |
try { | |
Thread.sleep(500); | |
etiquetaReloj.setText(formateador.format(LocalDateTime.now())); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
}; | |
Thread hilo = new Thread(runnable); | |
hilo.start(); | |
// Aquí pon el código que iría normalmente, en caso de que exista |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment