UTC时间值scala之间的差异

时间:2017-09-26 01:25:34

标签: scala scala-collections

我想在UTC中显示UTC当前时间与UTC值之间的差异。

1 个答案:

答案 0 :(得分:0)

以下情况如何?

import java.time._

val time1 = Instant.parse("2017-01-01T12:00:00Z")
val time2 = Instant.now()

val diff = Duration.between(time1, time2)

println("Difference is " + diff)

println("or in seconds: " + diff.getSeconds())

Try it here

进一步阅读: