Remaining Seconds?
avkorn opened this issue · 2 comments
avkorn commented
Hi @BastiaanJansen, is it possible somehow to get the number of seconds remaining for the TOTP?
BastiaanJansen commented
Hi @avkorn,
You could do something like this:
TOTP totp = TOTP.withDefaultValues(secret);
long timeInterval = totp.getPeriod().toMillis();
Duration remainder = Duration.ofMillis(timeInterval - System.currentTimeMillis() % timeInterval);
System.out.println(remainder.getSeconds());
avkorn commented
Many thanks!