This is an automated email from the ASF dual-hosted git repository.

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git


The following commit(s) were added to refs/heads/master by this push:
     new e8bafeb6a Internal refactoring
e8bafeb6a is described below

commit e8bafeb6a347f1cb529db6c4b33cc81ca069e337
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 27 21:36:42 2026 -0400

    Internal refactoring
---
 .../org/apache/commons/lang3/time/FastDateParser.java   | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java 
b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
index 0a4177790..e8b6a5537 100644
--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java
@@ -863,6 +863,15 @@ private int adjustYear(final int twoDigitYear) {
         return twoDigitYear >= startYear ? trial : trial + 100;
     }
 
+    private boolean checkLength(final String source, final ParsePosition pos) {
+        final int startIndex = pos.getIndex();
+        if (startIndex > source.length()) {
+            pos.setErrorIndex(startIndex);
+            return false;
+        }
+        return true;
+    }
+
     /**
      * Compares another object for equality with this object.
      *
@@ -1043,9 +1052,7 @@ public Date parse(final String source) throws 
ParseException {
      */
     @Override
     public Date parse(final String source, final ParsePosition pos) {
-        final int startIndex = pos.getIndex();
-        if (startIndex > source.length()) {
-            pos.setErrorIndex(startIndex);
+        if (!checkLength(source, pos)) {
             return null;
         }
         // timing tests indicate getting new instance is 19% faster than 
cloning
@@ -1067,9 +1074,7 @@ public Date parse(final String source, final 
ParsePosition pos) {
      */
     @Override
     public boolean parse(final String source, final ParsePosition pos, final 
Calendar calendar) {
-        final int startIndex = pos.getIndex();
-        if (startIndex > source.length()) {
-            pos.setErrorIndex(startIndex);
+        if (!checkLength(source, pos)) {
             return false;
         }
         final ListIterator<StrategyAndWidth> lt = patterns.listIterator();

Reply via email to