Add support for Instant in @DateTimeFormat
Closes gh-19846
This commit is contained in:
@@ -397,6 +397,15 @@ class DateTimeFormattingTests {
|
||||
assertThat(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31T12:00")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindInstantAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("styleInstant", "2017-02-21T13:00");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("styleInstant")).isEqualTo("2017-02-21T13:00");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
void testBindInstantFromJavaUtilDate() {
|
||||
@@ -622,6 +631,9 @@ class DateTimeFormattingTests {
|
||||
|
||||
private Instant instant;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm")
|
||||
private Instant styleInstant;
|
||||
|
||||
private Period period;
|
||||
|
||||
private Duration duration;
|
||||
@@ -762,6 +774,14 @@ class DateTimeFormattingTests {
|
||||
this.instant = instant;
|
||||
}
|
||||
|
||||
public Instant getStyleInstant() {
|
||||
return this.styleInstant;
|
||||
}
|
||||
|
||||
public void setStyleInstant(Instant styleInstant) {
|
||||
this.styleInstant = styleInstant;
|
||||
}
|
||||
|
||||
public Period getPeriod() {
|
||||
return this.period;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user