hi i want to calculate unixtime stamp with a ttl of 24 hours so that i can use it as a expiry time of 1 day for that i have tried the following code after doing some research
here is my code on scala
import java.time.Instant
import java.util.Date
val ttl:Long =24*3600
val unixTimeStamp =System.currentTimeMillis()/1000L + ttl
the above produces the output
1602071235
i just want to know is that the correct way of doing this in scala/java
Using the java.time
API introduced in Java 8 you only need to do this:
import java.time.{Duration, Instant}
Instant.now.plus(Duration.ofDays(1)).toEpochMilli