问题
How do I get the Scala UTC timestamp in seconds since January 1st, 1970?
回答1:
Same way as you would in Java:
val timestamp: Long = System.currentTimeMillis / 1000
回答2:
As of Java 8 it's possible to do so like so:
import java.time.Instant
unixTimestamp : Long = Instant.now.getEpochSecond
Via micha's answer here: https://stackoverflow.com/a/24703573/577199
来源:https://stackoverflow.com/questions/11352037/scala-utc-timestamp-in-seconds-since-january-1st-1970