In JavaFX, how can I display values which continuously change with time using \"label\" ?
How about using SimpleDateFormat? There's no need for the StringUtilities class!
private void bindToTime() {
Timeline timeline = new Timeline(
new KeyFrame(Duration.seconds(0),
new EventHandler() {
@Override public void handle(ActionEvent actionEvent) {
Calendar time = Calendar.getInstance();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
setText(simpleDateFormat.format(time.getTime()));
}
}
),
new KeyFrame(Duration.seconds(1))
);
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
}
}