Is there an elegant way to convert java.time.Duration
to scala.concurrent.duration.FiniteDuration
?
I am trying to do the following simple use of Config in Scala:
val d = ConfigFactory.load().getDuration("application.someTimeout")
However I don't see any simple way to use the result in Scala. Certainly hope the good people of Typesafe didn't expect me to do this:
FiniteDuration(d.getNano, TimeUnit.NANOSECONDS)
Edit: Note the line has a bug, which proves the point. See the selected answer below.