Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
f7135ff1
Commit
f7135ff1
authored
Aug 17, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ResolverStyle.SMART when a custom format is specified
Fixes gh-13970
parent
51fd27fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
WebConversionService.java
...k/boot/autoconfigure/web/format/WebConversionService.java
+1
-1
WebConversionServiceTests.java
...t/autoconfigure/web/format/WebConversionServiceTests.java
+9
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java
View file @
f7135ff1
...
@@ -89,7 +89,7 @@ public class WebConversionService extends DefaultFormattingConversionService {
...
@@ -89,7 +89,7 @@ public class WebConversionService extends DefaultFormattingConversionService {
DateTimeFormatterRegistrar
dateTime
=
new
DateTimeFormatterRegistrar
();
DateTimeFormatterRegistrar
dateTime
=
new
DateTimeFormatterRegistrar
();
if
(
this
.
dateFormat
!=
null
)
{
if
(
this
.
dateFormat
!=
null
)
{
dateTime
.
setDateFormatter
(
DateTimeFormatter
.
ofPattern
(
this
.
dateFormat
)
dateTime
.
setDateFormatter
(
DateTimeFormatter
.
ofPattern
(
this
.
dateFormat
)
.
withResolverStyle
(
ResolverStyle
.
S
TRIC
T
));
.
withResolverStyle
(
ResolverStyle
.
S
MAR
T
));
}
}
dateTime
.
registerFormatters
(
this
);
dateTime
.
registerFormatters
(
this
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java
View file @
f7135ff1
...
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link WebConversionService}.
* Tests for {@link WebConversionService}.
*
*
* @author Brian Clozel
* @author Brian Clozel
* @author Madhura Bhave
*/
*/
public
class
WebConversionServiceTests
{
public
class
WebConversionServiceTests
{
...
@@ -44,4 +45,12 @@ public class WebConversionServiceTests {
...
@@ -44,4 +45,12 @@ public class WebConversionServiceTests {
.
isEqualTo
(
"01*01*2018"
);
.
isEqualTo
(
"01*01*2018"
);
}
}
@Test
public
void
convertFromStringToDate
()
{
WebConversionService
conversionService
=
new
WebConversionService
(
"yyyy-MM-dd"
);
java
.
time
.
LocalDate
date
=
conversionService
.
convert
(
"2018-01-01"
,
java
.
time
.
LocalDate
.
class
);
assertThat
(
date
).
isEqualTo
(
java
.
time
.
LocalDate
.
of
(
2018
,
1
,
1
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment