Skip to content

Commit a88320f

Browse files
committed
Configure SimpleDateFormat to be strict during date parsing.
This change ensures that I don't do a mistake from c505b03 commit again. Addressed to #764
1 parent 88ce689 commit a88320f

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/main/java/ru/mystamps/web/controller/SitemapController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public void getSitemapXml(HttpServletResponse response) {
5454
response.setCharacterEncoding("UTF-8");
5555

5656
DateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH);
57+
dateFormatter.setLenient(false);
5758

5859
try {
5960
PrintWriter writer = response.getWriter();

src/test/java/ru/mystamps/web/tests/Random.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public static Date date() {
7676
try {
7777

7878
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
79+
fmt.setLenient(false);
7980
return between(fmt.parse("2017-01-01"), fmt.parse("2017-12-20")).date();
8081

8182
} catch (ParseException e) {

0 commit comments

Comments
 (0)