How to freeze CountdownClock component and read state

Hello,

I would like to freeze CountdownClock component before Count Down is ended on click button. Can you help me to understand, which listeners or events can I establish/fire? After stop count down I would like to know if Count down is 0 or it was stopped.

There is code for button and reset Count Down

    // button for stop count down table
    stopCountDown.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;
        @Override
        public void buttonClick(ClickEvent event) {
            
          try {
            countDownClock.setImmediate(true);
            // hide count down clock, better would to freeze the text
            countDownClock.setVisible(false);
            // force stop count down
            countDownClockEndEvent.countDownEnded(countDownClock);
            LOGGER.info("Inside click listener of stopCountDown button." + countDownClock.getState().);
            // TODO manage confirmation - get the actual course and realize conversion
          }
          catch (Exception ex) {
              LOGGER.error("Exception inside refresh table listener", ex);
            showNotification("Error:" + ex.getLocalizedMessage(), Type.ERROR_MESSAGE);
          }
        }
      });

Count Down establish:

    private void resetTimer() {
        countDownClock = new CountdownClock();
        ratesVerticalRight.addComponent(countDownClock);

        countDownClock.setEnabled(false);

        countDownClockEndEvent = new EndEventListener() {
            //@Override
            public void countDownEnded(CountdownClock clock) {
                LOGGER.info("Inside countDownEnded.");
                showNotification(
                                "Time is out or confirmed <br />"
                                + "next try... <br />", Type.HUMANIZED_MESSAGE);
            }
        };

        countDownClock.addEndEventListener(countDownClockEndEvent);

        System.out.println("State of clock: " +  countDownClock.getState().enabled);
        
        countDownClock.setEnabled(true);
        
        //event.getButton().setEnabled(false);
        Calendar c = Calendar.getInstance();
        c.add(Calendar.SECOND, 3);
        countDownClock.setDate(c.getTime());
        countDownClock.setFormat("<span style='font: bold 20px Arial; margin: 10px'>"
                        + "Countdown in %s.%ts seconds.</span>");

    }

Thank you forward for advice.

Still I don’t know how to do it. I solved it to stop CountDwn and hide text, but it is not what I would like.

I reviewed my question and it is not explained clearly. It is not needed necessarily to freeze the count down, but ony the count down text.