package org.deblauwe.whattimefx;

import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.util.Duration;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main extends Application {

    private Label timeLabel;
    private Label hexColorLabel;
    private GridPane gridPane;

    @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("What Colour Is It JavaFx?");

        timeLabel = new Label();
        timeLabel.getStyleClass().add("time-label");

        hexColorLabel = new Label();
        hexColorLabel.getStyleClass().add("hexcolor-label");
        hexColorLabel.setMaxWidth(Double.MAX_VALUE);

        gridPane = new GridPane();
        gridPane.setAlignment(Pos.CENTER);
        gridPane.setVgap(20);

        gridPane.add(timeLabel, 0, 0);
        gridPane.add(hexColorLabel, 0, 1);

        Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds();
        double width = visualBounds.getWidth();
        double height = visualBounds.getHeight();

        Scene value = new Scene(gridPane, width, height);
        value.getStylesheets().add("org/deblauwe/whattimefx/style.css");
        primaryStage.setScene(value);

        bindToTime();
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }

    private void bindToTime() {
        Timeline timeline = new Timeline(
                new KeyFrame(Duration.seconds(0),
                             new EventHandler<ActionEvent>() {
                                 @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();
    }

    private void setText(String format) {
        timeLabel.setText(format);
        String color = "#" + format.replaceAll(":", "");
        hexColorLabel.setText(color);
        gridPane.setBackground(new Background(new BackgroundFill(Color.web(color), null, null)));

    }

}

@@ -173,75 +173,8 @@
 on;%0A
-import javafx.event.ActionEvent;%0Aimport javafx.event.EventHandler;%0A
 impo
@@ -549,28 +549,25 @@
 va.t
-ext.SimpleDateFormat
+ime.ZonedDateTime
 ;%0Aim
@@ -580,20 +580,36 @@
 ava.
-u
 ti
-l.Calenda
+me.format.DateTimeFormatte
 r;%0A%0A
@@ -649,16 +649,123 @@
 tion %7B%0A%0A
+    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(%22HH:mm:ss%22);%0A%0A
     priv
@@ -2013,17 +2013,17 @@
 seconds(
-0
+1
 ),%0A     
@@ -2050,26 +2050,9 @@
     
-new EventHandler%3CA
+a
 ctio
@@ -2061,11 +2061,11 @@
 vent
-%3E()
+ -%3E
  %7B%0A 
@@ -2100,372 +2100,66 @@
     
-@Override%0A                                 public void handle(ActionEvent actionEvent) %7B%0A                                     Calendar time = Calendar.getInstance();%0A                                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat(%22HH:mm:ss%22);%0A                                     setText(simpleDateFormat.format(time.getTime
+setText(DATE_TIME_FORMATTER.format(ZonedDateTime.now
 ()));%0A
-    
     
@@ -2205,90 +2205,8 @@
     
-             %7D%0A                ),%0A                new KeyFrame(Duration.seconds(1)
 )%0A  

Use java.time classes instead of the old Calendar