Imagine I have a Duration value defined in my application.conf file. The documentation says it can parse Durations, but I can't see how.
timeout = 60 milliseconds
Can I parse it directly as a duration value? Ideally I would like to do something like this
val timeout = current.configuration.getMilliseconds("timeout")
(myActor ? GiveMeSomething)(timeout).mapTo[...]
but timeout is an Option[Long]. Thanks for any tips.
Play's configuration does support Duration, FiniteDuration and other Scala types. Use:
configuration.get[FiniteDuration]("path.to.duration")
The Configuration.get function takes an implicit ConfigLoader[A]. Play comes with a lot of implementations and easy to add additional ones.
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