I am a begginer programmer and have a very simple problem in scala, I want to convert a long var to Duration (import scala.concurrent.duration.Duration, import scala.concurrent.duration), in order to fit this code.
listener ! PiApproximation(pi, duration = (System.currentTimeMillis - start).millis)
Eclipse throws me the error that millis its not a member of Long, I am doing a tutorial for learning how to programme in Scala with Akka (https://github.com/fhelg/AkkaPlayGround/blob/master/PingPongApp.scala). And I think the code its correct, but i cant compile it because of that.
Any ideas? Many thanks in advance.
PD: My apologies for the bad english! I am from spain and we are not that good at language learning :P!
Scala provides implicit conversions which automatically/implicitly convert Int
s and Long
s:
scala> import scala.concurrent.duration._
import scala.concurrent.duration._
scala> (System.currentTimeMillis - 1234567890).millis
res0: scala.concurrent.duration.FiniteDuration = 1394598256075 milliseconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With