mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Added missing duration unit short names that are supported in scala.concurrent.duration.DurationConversions.
This commit is contained in:
parent
99afd721a5
commit
60c661d683
@ -512,12 +512,12 @@ final class SimpleConfig implements Config, MergeableValue, Serializable {
|
||||
unitString = unitString + "s";
|
||||
|
||||
// note that this is deliberately case-sensitive
|
||||
if (unitString.equals("") || unitString.equals("ms")
|
||||
if (unitString.equals("") || unitString.equals("ms") || unitString.equals("millis")
|
||||
|| unitString.equals("milliseconds")) {
|
||||
units = TimeUnit.MILLISECONDS;
|
||||
} else if (unitString.equals("us") || unitString.equals("microseconds")) {
|
||||
} else if (unitString.equals("us") || unitString.equals("micros") || unitString.equals("microseconds")) {
|
||||
units = TimeUnit.MICROSECONDS;
|
||||
} else if (unitString.equals("ns") || unitString.equals("nanoseconds")) {
|
||||
} else if (unitString.equals("ns") || unitString.equals("nanos") || unitString.equals("nanoseconds")) {
|
||||
units = TimeUnit.NANOSECONDS;
|
||||
} else if (unitString.equals("d") || unitString.equals("days")) {
|
||||
units = TimeUnit.DAYS;
|
||||
|
@ -54,7 +54,9 @@
|
||||
"second" : 1s,
|
||||
"secondsList" : [1s,2seconds,3 s, 4000],
|
||||
"secondAsNumber" : 1000,
|
||||
"halfSecond" : 0.5s
|
||||
"halfSecond" : 0.5s,
|
||||
"millis" : 1 milli,
|
||||
"micros" : 2000 micros
|
||||
},
|
||||
|
||||
"memsizes" : {
|
||||
|
@ -769,6 +769,8 @@ class ConfigTest extends TestUtils {
|
||||
assertEquals(Seq(1, 2, 3, 4) map s2unit,
|
||||
conf.getDurationList("durations.secondsList", unit).asScala)
|
||||
assertEquals(ms2unit(500L), conf.getDuration("durations.halfSecond", unit))
|
||||
assertEquals(ms2unit(1L), conf.getDuration("durations.millis", unit))
|
||||
assertEquals(ms2unit(2L), conf.getDuration("durations.micros", unit))
|
||||
}
|
||||
|
||||
assertDurationAsTimeUnit(NANOSECONDS)
|
||||
|
Loading…
Reference in New Issue
Block a user