Fallback to ISO-based default java.time type parsing
Closes gh-26985
This commit is contained in:
@@ -110,6 +110,15 @@ class DateTimeFormattingTests {
|
||||
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("10/31/09");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateWithISO() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDate", "2009-10-31");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("10/31/09");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateWithSpecificStyle() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
@@ -207,6 +216,15 @@ class DateTimeFormattingTests {
|
||||
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00 PM");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeWithISO() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localTime", "12:00:00");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00 PM");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalTimeWithSpecificStyle() {
|
||||
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
|
||||
@@ -260,6 +278,17 @@ class DateTimeFormattingTests {
|
||||
assertThat(value.endsWith("12:00 PM")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateTimeWithISO() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
propertyValues.add("localDateTime", "2009-10-31T12:00:00");
|
||||
binder.bind(propertyValues);
|
||||
assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
|
||||
String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
|
||||
assertThat(value.startsWith("10/31/09")).isTrue();
|
||||
assertThat(value.endsWith("12:00 PM")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBindLocalDateTimeAnnotated() {
|
||||
MutablePropertyValues propertyValues = new MutablePropertyValues();
|
||||
|
||||
Reference in New Issue
Block a user