[
https://issues.apache.org/jira/browse/LANG-1769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18020136#comment-18020136
]
Madhur Lathi commented on LANG-1769:
------------------------------------
Thanks [~pkarwasz] for the direction.
Raised PR [#1447|https://github.com/apache/commons-lang/pull/1447]
* Added methods: {{{}isLenient{}}}, {{setLenient}} and {{{}reset{}}}.
* Throws an exception for invalid input data and lenient is false.
* Added tests for new scenarios and confirmed all existing and new test cases
pass with {{{}mvn{}}}.
{{reset()}} method resets the object's state because the instance is cached and
reused.
> FastDateFormat only supports SimpleDateFormat lenient mode
> ----------------------------------------------------------
>
> Key: LANG-1769
> URL: https://issues.apache.org/jira/browse/LANG-1769
> Project: Commons Lang
> Issue Type: New Feature
> Components: lang.*
> Affects Versions: 3.17.0
> Reporter: Wang Hailong
> Priority: Minor
>
> the input is an invalid data, it should throw an exception, but the
> FastDateFormat.parse just parse it. The output is "Sun Jan 02 00:00:00 CST
> 10000
> "
> {color:#bbb529}@Test
> {color}{color:#cc7832}public void
> {color}{color:#ffc66d}testFastDateFormatWithInvalidMonth{color}()
> {color:#cc7832}throws {color}ParseException {
> {color:#808080}// Create a FastDateParser instance with a valid pattern string
> {color}{color:#808080} {color}FastDateFormat dateParser =
> FastDateFormat.getInstance({color:#6a8759}"MM/dd/yyyy"{color}{color:#cc7832},
> new {color}Locale({color:#6a8759}"en"{color}{color:#cc7832},
> {color}{color:#6a8759}"US"{color})){color:#cc7832};
> {color}{color:#cc7832} {color}{color:#808080}// Attempt to parse an invalid
> month value and expect an exception
> {color}{color:#808080}
> {color}System.{color:#9876aa}out{color}.println(dateParser.parse({color:#6a8759}"13/02/9999"{color})){color:#cc7832};
> {color}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)