Skip to content

Commit 0755ff4

Browse files
authored
Clarify requirements of strict date formats. (#29090)
Closes #29014
1 parent 695ec05 commit 0755ff4

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

docs/reference/mapping/params/format.asciidoc

+12-6
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html[i
4444
[[built-in-date-formats]]
4545
==== Built In Formats
4646

47-
Most of the below dates have a `strict` companion dates, which means, that
48-
year, month and day parts of the week must have prepending zeros in order
49-
to be valid. This means, that a date like `5/11/1` would not be valid, but
50-
you would need to specify the full date, which would be `2005/11/01` in this
51-
example. So instead of `date_optional_time` you would need to specify
52-
`strict_date_optional_time`.
47+
Most of the below formats have a `strict` companion format, which means that
48+
year, month and day parts of the week must use respectively 4, 2 and 2 digits
49+
exactly, potentially prepending zeros. For instance a date like `5/11/1` would
50+
be considered invalid and would need to be rewritten to `2005/11/01` to be
51+
accepted by the date parser.
52+
53+
To use them, you need to prepend `strict_` to the name of the date format, for
54+
instance `strict_date_optional_time` instead of `date_optional_time`.
55+
56+
These strict date formats are especially useful when
57+
<<date-detection,date fields are dynamically mapped>> in order to make sure to
58+
not accidentally map irrelevant strings as dates.
5359

5460
The following tables lists all the defaults ISO formats supported:
5561

server/src/main/java/org/joda/time/format/StrictISODateTimeFormat.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* class is named ISODatetimeFormat
2828
*
2929
* However there has been done one huge modification in several methods, which forces the date
30-
* year to be at least n digits, so that a year like "5" is invalid and must be "0005"
30+
* year to be exactly n digits, so that a year like "5" is invalid and must be "0005"
3131
*
3232
* All methods have been marked with an "// ES change" commentary
3333
*

0 commit comments

Comments
 (0)