Timeslot Calculations
The methods described on this page can be used to calculate time slot informations like the beginning or remaining time of a timeslot.
calculateTimeslotBeginning
Info
Calculates the start timestamp of the time slot in which the actual or given timestamp lies.
Usage
// measures current time of the clock, returns millis
totpGenerator.calculateTimeslotBeginning()
With a specific timestamp:
// with millis, returns millis
totpGenerator.calculateTimeslotBeginning(1656459878681)
// with Instant, returns Instant
totpGenerator.calculateTimeslotBeginning(Instant())
// with Date, returns Date
totpGenerator.calculateTimeslotBeginning(Date())
Arguments
Argument | Type | Default | Constraint |
---|---|---|---|
time | Long, Instant, Date | - | Optional |
calculateRemainingTime
Info
Calculates the remaining time as a Duration of the time slot in which the actual or given timestamp lies.
Usage
// measures current time of the clock, returns millis
totpGenerator.calculateRemainingTime()
With a specific timestamp:
// with millis
totpGenerator.calculateRemainingTime(1656459878681)
// with Instant
totpGenerator.calculateRemainingTime(Instant())
// with Date
totpGenerator.calculateRemainingTime(Date())
Arguments
Argument | Type | Default | Constraint |
---|---|---|---|
time | Long, Instant, Date | - | Optional |