Support Integer to Duration conversion during property binding
Closes gh-11216
This commit is contained in:
parent
8aeb245393
commit
e16579b416
|
|
@ -45,6 +45,7 @@ class DurationConverter implements GenericConverter {
|
||||||
static {
|
static {
|
||||||
Set<ConvertiblePair> types = new LinkedHashSet<>();
|
Set<ConvertiblePair> types = new LinkedHashSet<>();
|
||||||
types.add(new ConvertiblePair(String.class, Duration.class));
|
types.add(new ConvertiblePair(String.class, Duration.class));
|
||||||
|
types.add(new ConvertiblePair(Integer.class, Duration.class));
|
||||||
TYPES = Collections.unmodifiableSet(types);
|
TYPES = Collections.unmodifiableSet(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,13 @@ public class BinderConversionServiceTests {
|
||||||
assertThat(converted).isEqualTo(Duration.ofSeconds(10));
|
assertThat(converted).isEqualTo(Duration.ofSeconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void conversionServiceShouldSupportIntegerToDuration() throws Exception {
|
||||||
|
this.service = new BinderConversionService(null);
|
||||||
|
Duration converted = this.service.convert(10, Duration.class);
|
||||||
|
assertThat(converted).isEqualTo(Duration.ofMillis(10));
|
||||||
|
}
|
||||||
|
|
||||||
enum TestEnum {
|
enum TestEnum {
|
||||||
|
|
||||||
ONE, TWO
|
ONE, TWO
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue