Created
October 3, 2019 08:01
-
-
Save AlexBaitov/d34968e031c28e291f7f42263e6825ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ru.dgis.ams.owl | |
| import com.typesafe.config.{Config, ConfigFactory} | |
| import scala.concurrent.duration.{Duration, NANOSECONDS} | |
| object SimpleFiniteDurationParse extends App{ | |
| /** | |
| * A reader for for a scala.concurrent.duration.FiniteDuration. This reader should be able to read any valid duration | |
| * format as defined by the <a href="https://github.com/typesafehub/config/blob/master/HOCON.md">HOCON spec</a>. | |
| * For example, it can read "15 minutes" or "1 day". | |
| */ | |
| /** | |
| * As done in com.iheart/ficus_2.12/srcs/ficus_2.12-1.4.7-sources.jar!/net/ceedubs/ficus/readers/DurationReaders.scala:15 | |
| */ | |
| val config: Config = ConfigFactory.parseString("{asd=10 ms}") | |
| val nanos = config.getDuration("asd", NANOSECONDS) | |
| val duration = Duration.fromNanos(nanos) | |
| println( | |
| config, | |
| nanos, | |
| duration | |
| ) | |
| // (Config(SimpleConfigObject({"asd":"10 ms"})),10000000,10 milliseconds) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment