Clarify requirements of strict date formats. (#29090)

Closes #29014
This commit is contained in:
Adrien Grand 2018-03-16 14:39:36 +01:00 committed by GitHub
parent 695ec05160
commit 0755ff425f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 7 deletions

View File

@ -44,12 +44,18 @@ http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html[i
[[built-in-date-formats]] [[built-in-date-formats]]
==== Built In Formats ==== Built In Formats
Most of the below dates have a `strict` companion dates, which means, that Most of the below formats have a `strict` companion format, which means that
year, month and day parts of the week must have prepending zeros in order year, month and day parts of the week must use respectively 4, 2 and 2 digits
to be valid. This means, that a date like `5/11/1` would not be valid, but exactly, potentially prepending zeros. For instance a date like `5/11/1` would
you would need to specify the full date, which would be `2005/11/01` in this be considered invalid and would need to be rewritten to `2005/11/01` to be
example. So instead of `date_optional_time` you would need to specify accepted by the date parser.
`strict_date_optional_time`.
To use them, you need to prepend `strict_` to the name of the date format, for
instance `strict_date_optional_time` instead of `date_optional_time`.
These strict date formats are especially useful when
<<date-detection,date fields are dynamically mapped>> in order to make sure to
not accidentally map irrelevant strings as dates.
The following tables lists all the defaults ISO formats supported: The following tables lists all the defaults ISO formats supported:

View File

@ -27,7 +27,7 @@ import java.util.Set;
* class is named ISODatetimeFormat * class is named ISODatetimeFormat
* *
* However there has been done one huge modification in several methods, which forces the date * However there has been done one huge modification in several methods, which forces the date
* year to be at least n digits, so that a year like "5" is invalid and must be "0005" * year to be exactly n digits, so that a year like "5" is invalid and must be "0005"
* *
* All methods have been marked with an "// ES change" commentary * All methods have been marked with an "// ES change" commentary
* *