You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Michael J Chane (JIRA)" <ji...@apache.org> on 2013/03/16 07:44:12 UTC
[jira] [Created] (VALIDATOR-316) The
GenericTypeValidator.formateDate method handles the strict mode check
inproperly
Michael J Chane created VALIDATOR-316:
-----------------------------------------
Summary: The GenericTypeValidator.formateDate method handles the strict mode check inproperly
Key: VALIDATOR-316
URL: https://issues.apache.org/jira/browse/VALIDATOR-316
Project: Commons Validator
Issue Type: Bug
Components: Framework
Affects Versions: 1.3.1 Release, 1.4.0 Release
Reporter: Michael J Chane
Priority: Minor
When the strict mode is on, the GenericTypeValidator.formatDate(String value, String datePattern, boolean strict) method tests if the value.length() equals the datePattern.length().
This comparison does not take into consideration that the datePattern may contain single quotes to avoid some plain text being interpreted as pattern letters. For example, as described in SimpleDateFormat, "Wed, Jul 4, '01" is suitable for pattern "EEE, MMM d, ''yy" while the two strings have different length.
On the other hand, the length comparison doesn't work in some Locales. In Locale.CHINESE, the datePattern part "MMM" matches "三月" (two Chinese characters, literally "the third month"), while in Locale.JAPANESE, the datePattern part "EEE" matches "日" (single Japanese Kanji/Chinese character, literally "Sun" or "Day").
Even though the examples above are rarely used in production, the length comparison is still not acceptable. Setting lenient to true, or comparison between the original text and the formatted text from the result Date using the same pattern is better.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira