Added missing duration unit short names that are supported in scala.concurrent.duration.DurationConversions.

This commit is contained in:
Alex Wei 2014-08-08 09:48:56 +10:00
parent 99afd721a5
commit 60c661d683
3 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -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" : {

View File

@ -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)