You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/07/27 22:13:03 UTC

(commons-lang) branch master updated (e0dba35f9 -> 3d662f052)

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

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


    from e0dba35f9 [LANG-1833] Handle ParsePosition index beyond source string length cleanly (#1757)
     new 6fd967bf2 [LANG-1833] Handle ParsePosition index beyond source string length cleanly (#1757).
     new 3d662f052 [LANG-1833] Handle ParsePosition index beyond source string length cleanly (#1757).

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                            |  1 +
 .../apache/commons/lang3/time/DateUtilsTest.java   | 86 +++++++++++-----------
 .../commons/lang3/time/FastDateParserTest.java     | 22 +++---
 3 files changed, 55 insertions(+), 54 deletions(-)


(commons-lang) 01/02: [LANG-1833] Handle ParsePosition index beyond source string length cleanly (#1757).

Posted by gg...@apache.org.
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

commit 6fd967bf2047c3d1a3b00a4f746e08b459f8de1d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 27 22:12:06 2026 +0000

    [LANG-1833] Handle ParsePosition index beyond source string length
    cleanly (#1757).
---
 src/changes/changes.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index df05c3703..03c7059f7 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -251,6 +251,7 @@ java.lang.NullPointerException: Cannot invoke
     <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add Instants.toMillisSince(Instant) (#1683).</action>
     <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add CharUtils isHex(int), isAsciiNumeric(int), isOctal(int) (#1685).</action>
     <action                   type="add" dev="ggregory" due-to="Gary Gregory">Add and use Instants.toInstant(Instant[, Instant]) (#1690).</action>
+    <action issue="LANG-1833" type="add" dev="ggregory" due-to="Maksym Korshun">Handle ParsePosition index beyond source string length cleanly (#1757).</action>
     <!-- UPDATE -->
     <action                   type="update" dev="ggregory" due-to="Gary Gregory, Dependabot">Bump org.apache.commons:commons-parent from 92 to 103 #1498.</action>
     <action                   type="update" dev="ggregory" due-to="Gary Gregory">[test] Bump org.apache.commons:commons-text from 1.14.0 to 1.15.0.</action>


(commons-lang) 02/02: [LANG-1833] Handle ParsePosition index beyond source string length cleanly (#1757).

Posted by gg...@apache.org.
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

commit 3d662f052b5f0d62fc30e2e89e697c3637f644f4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Jul 27 22:12:56 2026 +0000

    [LANG-1833] Handle ParsePosition index beyond source string length
    cleanly (#1757).
    
    Sort members
---
 .../apache/commons/lang3/time/DateUtilsTest.java   | 86 +++++++++++-----------
 .../commons/lang3/time/FastDateParserTest.java     | 22 +++---
 2 files changed, 54 insertions(+), 54 deletions(-)

diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
index 45fe80908..69af27687 100644
--- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java
@@ -1649,49 +1649,6 @@ void testTruncate_Bugzilla_31395() throws Exception {
         assertEquals(0, cal.get(Calendar.HOUR));
     }
 
-    /**
-     * Tests for LANG-59
-     *
-     * see https://issues.apache.org/jira/browse/LANG-59
-     */
-    @Test
-    void testTruncateLang59() {
-        // Set TimeZone to Mountain Time
-        final TimeZone denverZone = TimeZones.getTimeZone("America/Denver");
-        TimeZone.setDefault(denverZone);
-        final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS XXX");
-        format.setTimeZone(denverZone);
-        final Date oct31_01MDT = new Date(1099206000000L);
-        final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
-        final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
-        final Date oct31_01_02_03MDT = new Date(oct31_01_02MDT.getTime() + 3000L); // + 3 seconds
-        final Date oct31_01_02_03_04MDT = new Date(oct31_01_02_03MDT.getTime() + 4L); // + 4 milliseconds
-        assertEquals("2004-10-31 00:00:00.000 -06:00", format.format(oct31MDT), "Check 00:00:00.000");
-        assertEquals("2004-10-31 01:00:00.000 -06:00", format.format(oct31_01MDT), "Check 01:00:00.000");
-        assertEquals("2004-10-31 01:02:00.000 -06:00", format.format(oct31_01_02MDT), "Check 01:02:00.000");
-        assertEquals("2004-10-31 01:02:03.000 -06:00", format.format(oct31_01_02_03MDT), "Check 01:02:03.000");
-        assertEquals("2004-10-31 01:02:03.004 -06:00", format.format(oct31_01_02_03_04MDT), "Check 01:02:03.004");
-        // Demonstrate Problem
-        final Calendar gval = Calendar.getInstance();
-        gval.setTime(new Date(oct31_01MDT.getTime()));
-        gval.set(Calendar.MINUTE, gval.get(Calendar.MINUTE)); // set minutes to the same value
-        assertEquals(gval.getTime().getTime(), oct31_01MDT.getTime() + 3600000L, "Demonstrate Problem");
-        // Test Truncate
-        assertEquals(oct31_01_02_03_04MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.MILLISECOND), "Truncate Calendar.MILLISECOND");
-        assertEquals(oct31_01_02_03MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.SECOND), "Truncate Calendar.SECOND");
-        assertEquals(oct31_01_02MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.MINUTE), "Truncate Calendar.MINUTE");
-        assertEquals(oct31_01MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.HOUR_OF_DAY), "Truncate Calendar.HOUR_OF_DAY");
-        assertEquals(oct31_01MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.HOUR), "Truncate Calendar.HOUR");
-        assertEquals(oct31MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.DATE), "Truncate Calendar.DATE");
-        // Test Round (down)
-        assertEquals(oct31_01_02_03_04MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.MILLISECOND), "Round Calendar.MILLISECOND");
-        assertEquals(oct31_01_02_03MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.SECOND), "Round Calendar.SECOND");
-        assertEquals(oct31_01_02MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.MINUTE), "Round Calendar.MINUTE");
-        assertEquals(oct31_01MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.HOUR_OF_DAY), "Round Calendar.HOUR_OF_DAY");
-        assertEquals(oct31_01MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.HOUR), "Round Calendar.HOUR");
-        assertEquals(oct31MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.DATE), "Round Calendar.DATE");
-    }
-
     @Test
     public void testTruncatedCompareToCalendar() {
         final Calendar cal1 = Calendar.getInstance();
@@ -1757,6 +1714,49 @@ public void testTruncatedEqualDate() {
         assertThrows(NullPointerException.class, () -> DateUtils.truncatedEquals(date1, null, Calendar.DAY_OF_MONTH));
     }
 
+    /**
+     * Tests for LANG-59
+     *
+     * see https://issues.apache.org/jira/browse/LANG-59
+     */
+    @Test
+    void testTruncateLang59() {
+        // Set TimeZone to Mountain Time
+        final TimeZone denverZone = TimeZones.getTimeZone("America/Denver");
+        TimeZone.setDefault(denverZone);
+        final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS XXX");
+        format.setTimeZone(denverZone);
+        final Date oct31_01MDT = new Date(1099206000000L);
+        final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour
+        final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes
+        final Date oct31_01_02_03MDT = new Date(oct31_01_02MDT.getTime() + 3000L); // + 3 seconds
+        final Date oct31_01_02_03_04MDT = new Date(oct31_01_02_03MDT.getTime() + 4L); // + 4 milliseconds
+        assertEquals("2004-10-31 00:00:00.000 -06:00", format.format(oct31MDT), "Check 00:00:00.000");
+        assertEquals("2004-10-31 01:00:00.000 -06:00", format.format(oct31_01MDT), "Check 01:00:00.000");
+        assertEquals("2004-10-31 01:02:00.000 -06:00", format.format(oct31_01_02MDT), "Check 01:02:00.000");
+        assertEquals("2004-10-31 01:02:03.000 -06:00", format.format(oct31_01_02_03MDT), "Check 01:02:03.000");
+        assertEquals("2004-10-31 01:02:03.004 -06:00", format.format(oct31_01_02_03_04MDT), "Check 01:02:03.004");
+        // Demonstrate Problem
+        final Calendar gval = Calendar.getInstance();
+        gval.setTime(new Date(oct31_01MDT.getTime()));
+        gval.set(Calendar.MINUTE, gval.get(Calendar.MINUTE)); // set minutes to the same value
+        assertEquals(gval.getTime().getTime(), oct31_01MDT.getTime() + 3600000L, "Demonstrate Problem");
+        // Test Truncate
+        assertEquals(oct31_01_02_03_04MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.MILLISECOND), "Truncate Calendar.MILLISECOND");
+        assertEquals(oct31_01_02_03MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.SECOND), "Truncate Calendar.SECOND");
+        assertEquals(oct31_01_02MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.MINUTE), "Truncate Calendar.MINUTE");
+        assertEquals(oct31_01MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.HOUR_OF_DAY), "Truncate Calendar.HOUR_OF_DAY");
+        assertEquals(oct31_01MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.HOUR), "Truncate Calendar.HOUR");
+        assertEquals(oct31MDT, DateUtils.truncate(oct31_01_02_03_04MDT, Calendar.DATE), "Truncate Calendar.DATE");
+        // Test Round (down)
+        assertEquals(oct31_01_02_03_04MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.MILLISECOND), "Round Calendar.MILLISECOND");
+        assertEquals(oct31_01_02_03MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.SECOND), "Round Calendar.SECOND");
+        assertEquals(oct31_01_02MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.MINUTE), "Round Calendar.MINUTE");
+        assertEquals(oct31_01MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.HOUR_OF_DAY), "Round Calendar.HOUR_OF_DAY");
+        assertEquals(oct31_01MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.HOUR), "Round Calendar.HOUR");
+        assertEquals(oct31MDT, DateUtils.round(oct31_01_02_03_04MDT, Calendar.DATE), "Round Calendar.DATE");
+    }
+
     /**
      * Tests the calendar iterator for week ranges
      */
diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
index 2cf6ebf8a..4c3c1538c 100644
--- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java
@@ -563,6 +563,17 @@ void testParseNumerics(final TriFunction<String, TimeZone, Locale, DateParser> d
         assertEquals(cal.getTime(), fdf.parse("20030210153320989"));
     }
 
+    @Test
+    void testParseOffset() {
+        final DateParser parser = getInstance(YMD_SLASH);
+        final Date date = parser.parse("Today is 2015/07/04", new ParsePosition(9));
+
+        final Calendar cal = Calendar.getInstance();
+        cal.clear();
+        cal.set(2015, Calendar.JULY, 4);
+        assertEquals(cal.getTime(), date);
+    }
+
     @Test
     public void testParsePositionBeyondInputLength() {
         final String source = "Jan";
@@ -584,17 +595,6 @@ public void testParsePositionBeyondInputLength() {
         }
     }
 
-    @Test
-    void testParseOffset() {
-        final DateParser parser = getInstance(YMD_SLASH);
-        final Date date = parser.parse("Today is 2015/07/04", new ParsePosition(9));
-
-        final Calendar cal = Calendar.getInstance();
-        cal.clear();
-        cal.set(2015, Calendar.JULY, 4);
-        assertEquals(cal.getTime(), date);
-    }
-
     @CartesianTest
     @CartesianTest.MethodFactory("testParsesFactory")
     // Check that all Locales can parse the formats we use