Groovy web console

subscribe to the feed Subscribe
to this

Timestamp with duration

Published 2 months ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.sql.Timestamp
import java.time.temporal.ChronoUnit
import java.time.Duration

long nowMilis = System.currentTimeMillis()

println "In 1 hour: ${new Timestamp(nowMilis + Duration.of(1, ChronoUnit.HOURS).toMillis())}"
println "In 1 day: ${new Timestamp(nowMilis + Duration.of(1, ChronoUnit.DAYS).toMillis())}"
// println "In 1 month: ${new Timestamp(nowMilis + Duration.of(1, ChronoUnit.MONTHS).toMillis())}"