@FXML
public void initialize() {
Timeline clock = new Timeline(new KeyFrame(Duration.ZERO, e -> {
LocalTime currentTime = LocalTime.now();
time.setText(currentTime.getHour() + ":" + currentTime.getMinute() + ":" + currentTime.getSecond());
}),
new KeyFrame(Duration.seconds(1))
);
clock.setCycleCount(Animation.INDEFINITE);
clock.play();
}
@FXML
public void initialize() {
Timeline clock = new Timeline(new KeyFrame(Duration.ZERO, e ->
time.setText(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")))
),
new KeyFrame(Duration.seconds(1))
);
clock.setCycleCount(Animation.INDEFINITE);
clock.play();
}