I want to add a count down timer on a resend OTP button when the timer reaches to 00:00 i want my resend OTP button to be enabled can anyone guide me how can i do this.
private void startTimer() {
int initialCountdownValue = 30;
final int[] countdownValue = { initialCountdownValue };
timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
countdownValue[0]–;
log.info(" Outside iFF Value: " + countdownValue[0]);
if (countdownValue[0] == 0) {
log.info(" iFF Value: " + countdownValue[0]);
timer.cancel();
resendOtpBtn.setEnabled(true);
} else {
log.info("inside else");
int minutes = countdownValue[0] / 60;
int seconds = countdownValue[0] % 60;
formattedTime = String.format("%d:%02d", minutes, seconds);
//ui.access(() -> countdownLabel.setValue(formattedTime));
countdownLabel.setValue(formattedTime);
}
}
}, 0, 1000);
}
/*@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
startTimer();
}`Preformatted text
i have used this code but my timer value is not changing on front end.