@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2023 the original author or authors .
* Copyright 2002 - 2024 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -105,7 +105,7 @@ class DateTimeFormattingTests {
@@ -105,7 +105,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , "10/31/09" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localDate" ) ) . isEqualTo ( "10/31/09" ) ;
}
@ -117,7 +117,7 @@ class DateTimeFormattingTests {
@@ -117,7 +117,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , "October 31, 2009" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localDate" ) ) . isEqualTo ( "October 31, 2009" ) ;
}
@ -129,7 +129,7 @@ class DateTimeFormattingTests {
@@ -129,7 +129,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , "20091031" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localDate" ) ) . isEqualTo ( "20091031" ) ;
}
@ -138,7 +138,7 @@ class DateTimeFormattingTests {
@@ -138,7 +138,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , new String [ ] { "10/31/09" } ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
}
@Test
@ -146,7 +146,7 @@ class DateTimeFormattingTests {
@@ -146,7 +146,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "styleLocalDate" , "Oct 31, 2009" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "styleLocalDate" ) ) . isEqualTo ( "Oct 31, 2009" ) ;
}
@ -164,7 +164,7 @@ class DateTimeFormattingTests {
@@ -164,7 +164,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "children[0].styleLocalDate" , "Oct 31, 2009" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "children[0].styleLocalDate" ) ) . isEqualTo ( "Oct 31, 2009" ) ;
}
@ -174,7 +174,7 @@ class DateTimeFormattingTests {
@@ -174,7 +174,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "styleLocalDate" , "Oct 31, 2009" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "styleLocalDate" ) ) . isEqualTo ( "Oct 31, 2009" ) ;
}
@ -193,7 +193,7 @@ class DateTimeFormattingTests {
@@ -193,7 +193,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDate" , new GregorianCalendar ( 2009 , 9 , 31 , 0 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localDate" ) ) . isEqualTo ( "10/31/09" ) ;
}
@ -202,7 +202,7 @@ class DateTimeFormattingTests {
@@ -202,7 +202,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localTime" , "12:00 PM" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localTime" ) ) . isEqualTo ( "12:00 PM" ) ;
}
@ -214,7 +214,7 @@ class DateTimeFormattingTests {
@@ -214,7 +214,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localTime" , "12:00:00 PM" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localTime" ) ) . isEqualTo ( "12:00:00 PM" ) ;
}
@ -226,7 +226,7 @@ class DateTimeFormattingTests {
@@ -226,7 +226,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localTime" , "130000" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localTime" ) ) . isEqualTo ( "130000" ) ;
}
@ -235,7 +235,7 @@ class DateTimeFormattingTests {
@@ -235,7 +235,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "styleLocalTime" , "12:00:00 PM" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "styleLocalTime" ) ) . isEqualTo ( "12:00:00 PM" ) ;
}
@ -244,7 +244,7 @@ class DateTimeFormattingTests {
@@ -244,7 +244,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localTime" , new GregorianCalendar ( 1970 , 0 , 0 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "localTime" ) ) . isEqualTo ( "12:00 PM" ) ;
}
@ -253,10 +253,9 @@ class DateTimeFormattingTests {
@@ -253,10 +253,9 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDateTime" , LocalDateTime . of ( 2009 , 10 , 31 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
String value = binder . getBindingResult ( ) . getFieldValue ( "localDateTime" ) . toString ( ) ;
assertThat ( value . startsWith ( "10/31/09" ) ) . isTrue ( ) ;
assertThat ( value . endsWith ( "12:00 PM" ) ) . isTrue ( ) ;
assertThat ( value ) . startsWith ( "10/31/09" ) . endsWith ( "12:00 PM" ) ;
}
@Test
@ -264,10 +263,9 @@ class DateTimeFormattingTests {
@@ -264,10 +263,9 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "styleLocalDateTime" , LocalDateTime . of ( 2009 , 10 , 31 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
String value = binder . getBindingResult ( ) . getFieldValue ( "styleLocalDateTime" ) . toString ( ) ;
assertThat ( value . startsWith ( "Oct 31, 2009" ) ) . isTrue ( ) ;
assertThat ( value . endsWith ( "12:00:00 PM" ) ) . isTrue ( ) ;
assertThat ( value ) . startsWith ( "Oct 31, 2009" ) . endsWith ( "12:00:00 PM" ) ;
}
@Test
@ -275,10 +273,9 @@ class DateTimeFormattingTests {
@@ -275,10 +273,9 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDateTime" , new GregorianCalendar ( 2009 , 9 , 31 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
String value = binder . getBindingResult ( ) . getFieldValue ( "localDateTime" ) . toString ( ) ;
assertThat ( value . startsWith ( "10/31/09" ) ) . isTrue ( ) ;
assertThat ( value . endsWith ( "12:00 PM" ) ) . isTrue ( ) ;
assertThat ( value ) . startsWith ( "10/31/09" ) . endsWith ( "12:00 PM" ) ;
}
@Test
@ -289,10 +286,9 @@ class DateTimeFormattingTests {
@@ -289,10 +286,9 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "localDateTime" , LocalDateTime . of ( 2009 , 10 , 31 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
String value = binder . getBindingResult ( ) . getFieldValue ( "localDateTime" ) . toString ( ) ;
assertThat ( value . startsWith ( "Oct 31, 2009" ) ) . isTrue ( ) ;
assertThat ( value . endsWith ( "12:00:00 PM" ) ) . isTrue ( ) ;
assertThat ( value ) . startsWith ( "Oct 31, 2009" ) . endsWith ( "12:00:00 PM" ) ;
}
@Test
@ -300,7 +296,7 @@ class DateTimeFormattingTests {
@@ -300,7 +296,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "patternLocalDateTime" , "10/31/09 12:00 PM" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "patternLocalDateTime" ) ) . isEqualTo ( "10/31/09 12:00 PM" ) ;
}
@ -317,7 +313,7 @@ class DateTimeFormattingTests {
@@ -317,7 +313,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "isoLocalDate" , "2009-10-31" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "isoLocalDate" ) ) . isEqualTo ( "2009-10-31" ) ;
}
@ -356,7 +352,7 @@ class DateTimeFormattingTests {
@@ -356,7 +352,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "isoLocalTime" , "12:00:00" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "isoLocalTime" ) ) . isEqualTo ( "12:00:00" ) ;
}
@ -365,7 +361,7 @@ class DateTimeFormattingTests {
@@ -365,7 +361,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "isoLocalTime" , "12:00:00.000-05:00" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "isoLocalTime" ) ) . isEqualTo ( "12:00:00" ) ;
}
@ -374,7 +370,7 @@ class DateTimeFormattingTests {
@@ -374,7 +370,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "isoLocalDateTime" , "2009-10-31T12:00:00" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "isoLocalDateTime" ) ) . isEqualTo ( "2009-10-31T12:00:00" ) ;
}
@ -383,7 +379,7 @@ class DateTimeFormattingTests {
@@ -383,7 +379,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "isoLocalDateTime" , "2009-10-31T12:00:00.000Z" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "isoLocalDateTime" ) ) . isEqualTo ( "2009-10-31T12:00:00" ) ;
}
@ -392,8 +388,8 @@ class DateTimeFormattingTests {
@@ -392,8 +388,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "instant" , "2009-10-31T12:00:00.000Z" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "instant" ) . toString ( ) . startsWith ( "2009-10-31T12:00" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "instant" ) . toString ( ) ) . startsWith ( "2009-10-31T12:00" ) ;
}
@Test
@ -405,8 +401,8 @@ class DateTimeFormattingTests {
@@ -405,8 +401,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "instant" , new Date ( 109 , 9 , 31 , 12 , 0 ) ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "instant" ) . toString ( ) . startsWith ( "2009-10-31" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "instant" ) . toString ( ) ) . startsWith ( "2009-10-31" ) ;
}
finally {
TimeZone . setDefault ( defaultZone ) ;
@ -418,8 +414,8 @@ class DateTimeFormattingTests {
@@ -418,8 +414,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "period" , "P6Y3M1D" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "period" ) . toString ( ) . equals ( "P6Y3M1D" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "period" ) . toString ( ) ) . isEqualTo ( "P6Y3M1D" ) ;
}
@Test
@ -427,8 +423,8 @@ class DateTimeFormattingTests {
@@ -427,8 +423,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "duration" , "PT8H6M12.345S" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "duration" ) . toString ( ) . equals ( "PT8H6M12.345S" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "duration" ) . toString ( ) ) . isEqualTo ( "PT8H6M12.345S" ) ;
}
@Test
@ -436,8 +432,8 @@ class DateTimeFormattingTests {
@@ -436,8 +432,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "year" , "2007" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "year" ) . toString ( ) . equals ( "2007" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "year" ) . toString ( ) ) . isEqualTo ( "2007" ) ;
}
@Test
@ -445,8 +441,8 @@ class DateTimeFormattingTests {
@@ -445,8 +441,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "month" , "JULY" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "month" ) . toString ( ) . equals ( "JULY" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "month" ) . toString ( ) ) . isEqualTo ( "JULY" ) ;
}
@Test
@ -454,8 +450,8 @@ class DateTimeFormattingTests {
@@ -454,8 +450,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "month" , "July" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "month" ) . toString ( ) . equals ( "JULY" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "month" ) . toString ( ) ) . isEqualTo ( "JULY" ) ;
}
@Test
@ -463,8 +459,8 @@ class DateTimeFormattingTests {
@@ -463,8 +459,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "yearMonth" , "2007-12" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "yearMonth" ) . toString ( ) . equals ( "2007-12" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "yearMonth" ) . toString ( ) ) . isEqualTo ( "2007-12" ) ;
}
@Test
@ -472,10 +468,11 @@ class DateTimeFormattingTests {
@@ -472,10 +468,11 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues ( ) ;
propertyValues . add ( "monthDay" , "--12-03" ) ;
binder . bind ( propertyValues ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "monthDay" ) . toString ( ) . equals ( "--12-03" ) ) . isTrue ( ) ;
assertThat ( binder . getBindingResult ( ) . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( binder . getBindingResult ( ) . getFieldValue ( "monthDay" ) . toString ( ) ) . isEqualTo ( "--12-03" ) ;
}
@Nested
class FallbackPatternTests {
@ -487,7 +484,7 @@ class DateTimeFormattingTests {
@@ -487,7 +484,7 @@ class DateTimeFormattingTests {
propertyValues . add ( propertyName , propertyValue ) ;
binder . bind ( propertyValues ) ;
BindingResult bindingResult = binder . getBindingResult ( ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( bindingResult . getFieldValue ( propertyName ) ) . isEqualTo ( "3/2/21" ) ;
}
@ -499,11 +496,12 @@ class DateTimeFormattingTests {
@@ -499,11 +496,12 @@ class DateTimeFormattingTests {
propertyValues . add ( propertyName , propertyValue ) ;
binder . bind ( propertyValues ) ;
BindingResult bindingResult = binder . getBindingResult ( ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( bindingResult . getFieldValue ( propertyName ) ) . isEqualTo ( "2021-03-02" ) ;
}
@ParameterizedTest ( name = "input date: {0}" )
// @ValueSource(strings = {"12:00:00\u202FPM", "12:00:00", "12:00"})
@ValueSource ( strings = { "12:00:00 PM" , "12:00:00" , "12:00" } )
void styleLocalTime ( String propertyValue ) {
String propertyName = "styleLocalTimeWithFallbackPatterns" ;
@ -511,7 +509,8 @@ class DateTimeFormattingTests {
@@ -511,7 +509,8 @@ class DateTimeFormattingTests {
propertyValues . add ( propertyName , propertyValue ) ;
binder . bind ( propertyValues ) ;
BindingResult bindingResult = binder . getBindingResult ( ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isZero ( ) ;
// assertThat(bindingResult.getFieldValue(propertyName)).asString().matches("12:00:00\\SPM");
assertThat ( bindingResult . getFieldValue ( propertyName ) ) . isEqualTo ( "12:00:00 PM" ) ;
}
@ -523,7 +522,7 @@ class DateTimeFormattingTests {
@@ -523,7 +522,7 @@ class DateTimeFormattingTests {
propertyValues . add ( propertyName , propertyValue ) ;
binder . bind ( propertyValues ) ;
BindingResult bindingResult = binder . getBindingResult ( ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isEqualTo ( 0 ) ;
assertThat ( bindingResult . getErrorCount ( ) ) . isZero ( ) ;
assertThat ( bindingResult . getFieldValue ( propertyName ) ) . isEqualTo ( "2021-03-02T12:00:00" ) ;
}
@ -565,10 +564,10 @@ class DateTimeFormattingTests {
@@ -565,10 +564,10 @@ class DateTimeFormattingTests {
@DateTimeFormat ( style = "M-" )
private LocalDate styleLocalDate ;
@DateTimeFormat ( style = "S-" , fallbackPatterns = { "yyyy-MM-dd" , "yyyyMMdd" , "yyyy.MM.dd" } )
@DateTimeFormat ( style = "S-" , fallbackPatterns = { "yyyy-MM-dd" , "yyyyMMdd" , "yyyy.MM.dd" } )
private LocalDate styleLocalDateWithFallbackPatterns ;
@DateTimeFormat ( pattern = "yyyy-MM-dd" , fallbackPatterns = { "M/d/yy" , "yyyyMMdd" , "yyyy.MM.dd" } )
@DateTimeFormat ( pattern = "yyyy-MM-dd" , fallbackPatterns = { "M/d/yy" , "yyyyMMdd" , "yyyy.MM.dd" } )
private LocalDate patternLocalDateWithFallbackPatterns ;
private LocalTime localTime ;
@ -576,7 +575,7 @@ class DateTimeFormattingTests {
@@ -576,7 +575,7 @@ class DateTimeFormattingTests {
@DateTimeFormat ( style = "-M" )
private LocalTime styleLocalTime ;
@DateTimeFormat ( style = "-M" , fallbackPatterns = { "HH:mm:ss" , "HH:mm" } )
@DateTimeFormat ( style = "-M" , fallbackPatterns = { "HH:mm:ss" , "HH:mm" } )
private LocalTime styleLocalTimeWithFallbackPatterns ;
private LocalDateTime localDateTime ;
@ -596,7 +595,7 @@ class DateTimeFormattingTests {
@@ -596,7 +595,7 @@ class DateTimeFormattingTests {
@DateTimeFormat ( iso = ISO . DATE_TIME )
private LocalDateTime isoLocalDateTime ;
@DateTimeFormat ( iso = ISO . DATE_TIME , fallbackPatterns = { "yyyy-MM-dd HH:mm:ss" , "M/d/yy HH:mm" } )
@DateTimeFormat ( iso = ISO . DATE_TIME , fallbackPatterns = { "yyyy-MM-dd HH:mm:ss" , "M/d/yy HH:mm" } )
private LocalDateTime isoLocalDateTimeWithFallbackPatterns ;
private Instant instant ;
@ -615,7 +614,6 @@ class DateTimeFormattingTests {
@@ -615,7 +614,6 @@ class DateTimeFormattingTests {
private final List < DateTimeBean > children = new ArrayList < > ( ) ;
public LocalDate getLocalDate ( ) {
return this . localDate ;
}