tano February 2016

Play framework - parse duration parameter in configuration file

Play! official documentation on the configuration file says that it is possible to specify duration variables using proper keywords.

How do I retrieve those variables in my application? I mean, in order to read a String variable I use:

val conf = Play.configuration.getString("name.of.the.variable").get

But I don't see any Play.configuration.getDuration() or similar function.

Thanks.

Answers


tano February 2016

I've found the solution:

    val conf: FiniteDuration = Play.configuration.getMilliseconds("foo.bar").get milliseconds


mkurz February 2016

Try:

import scala.concurrent.duration._
val bindTimeout = Play.configuration.get[Duration]("name.of.the.variable")

Post Status

Asked in February 2016
Viewed 3,503 times
Voted 14
Answered 2 times

Search




Leave an answer