mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Added more duration unit short names for hour, minute and second.
This commit is contained in:
parent
60c661d683
commit
ebb526304e
@ -521,11 +521,11 @@ final class SimpleConfig implements Config, MergeableValue, Serializable {
|
||||
units = TimeUnit.NANOSECONDS;
|
||||
} else if (unitString.equals("d") || unitString.equals("days")) {
|
||||
units = TimeUnit.DAYS;
|
||||
} else if (unitString.equals("h") || unitString.equals("hours")) {
|
||||
} else if (unitString.equals("h") || unitString.equals("hours") || unitString.equals("hr") || unitString.equals("hrs")) {
|
||||
units = TimeUnit.HOURS;
|
||||
} else if (unitString.equals("s") || unitString.equals("seconds")) {
|
||||
} else if (unitString.equals("s") || unitString.equals("seconds") || unitString.equals("secs")) {
|
||||
units = TimeUnit.SECONDS;
|
||||
} else if (unitString.equals("m") || unitString.equals("minutes")) {
|
||||
} else if (unitString.equals("m") || unitString.equals("minutes") || unitString.equals("mins")) {
|
||||
units = TimeUnit.MINUTES;
|
||||
} else {
|
||||
throw new ConfigException.BadValue(originForException,
|
||||
|
@ -56,7 +56,10 @@
|
||||
"secondAsNumber" : 1000,
|
||||
"halfSecond" : 0.5s,
|
||||
"millis" : 1 milli,
|
||||
"micros" : 2000 micros
|
||||
"micros" : 2000 micros,
|
||||
"secs" : 2 sec,
|
||||
"mins" : 1 min,
|
||||
"hrs" : 1 hr
|
||||
},
|
||||
|
||||
"memsizes" : {
|
||||
|
@ -771,6 +771,9 @@ class ConfigTest extends TestUtils {
|
||||
assertEquals(ms2unit(500L), conf.getDuration("durations.halfSecond", unit))
|
||||
assertEquals(ms2unit(1L), conf.getDuration("durations.millis", unit))
|
||||
assertEquals(ms2unit(2L), conf.getDuration("durations.micros", unit))
|
||||
assertEquals(ms2unit(2000L), conf.getDuration("durations.secs", unit))
|
||||
assertEquals(ms2unit(60000L), conf.getDuration("durations.mins", unit))
|
||||
assertEquals(ms2unit(3600000L), conf.getDuration("durations.hrs", unit))
|
||||
}
|
||||
|
||||
assertDurationAsTimeUnit(NANOSECONDS)
|
||||
|
Loading…
Reference in New Issue
Block a user