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 f713b4fc1 LANG-1465: Clarify DateUtils time zone parsing Javadoc
f713b4fc1 is described below

commit f713b4fc1a681db2ee368847ae826c638691ba86
Author: Gary Gregory <[email protected]>
AuthorDate: Sun Nov 29 09:10:01 2026 -0500

    LANG-1465: Clarify DateUtils time zone parsing Javadoc
    
    The reported compatibility break between 3.4 and 3.5 is reproducible,
    but current ZZ parsing matches its documented contract: accept Z or
    a colon-separated offset such as -05:00, and reject -0500.
    
    Restoring the older behavior would introduce another compatibility
    change. Applications may rely on rejection, and accepting additional
    inputs can change which pattern DateUtils selects and therefore the
    returned date. The proposed shared-strategy change also unintentionally
    relaxes XXX parsing.
    
    Clarify the DateUtils Javadoc instead. Link to FastDateParser, explain
    the timezone differences from SimpleDateFormat, and identify Z or XX
    as alternatives for offsets without colons. Apply this clarification
    to all parsing overloads and record it in changes.xml.
---
 src/changes/changes.xml                            |  1 +
 .../org/apache/commons/lang3/time/DateUtils.java   | 33 ++++++++++++++++++----
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index acdaeaaab..f22ecf4ce 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -126,6 +126,7 @@ The <action> type attribute can be add,update,fix,remove.
     <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Javadoc: Correct ArrayUtils.indexesOf(boolean[], boolean, int) to 
describe an empty BitSet instead of the -1 index sentinel.</action>
     <action                   type="fix" dev="ggregory" due-to="Gary 
Gregory">Javadoc: Remove incorrect integer-rounding descriptions from both 
ArrayUtils.indexesOf overloads with a double tolerance.</action>
     <action                   type="fix" dev="ggregory" due-to="crowmagnumb, 
Gary Gregory">Render enum values using toString() in recursive toString styles, 
including constants with class bodies (#1509, #1898).</action>
+    <action issue="LANG-1465" type="fix" dev="ggregory" due-to="xia0c, Gary 
Gregory">Javadoc: Clarify ZZ time zone parsing and the Z and XX alternatives in 
DateUtils.</action>
     <!-- ADD -->
     <!-- UPDATE -->
   </release>
diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java 
b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
index d5f027552..cac5468a2 100644
--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java
+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java
@@ -61,7 +61,8 @@
  * </p>
  *
  * <p>
- * Date parsing uses {@link java.text.SimpleDateFormat} patterns. The {@code 
S} pattern letter represents the millisecond field,
+ * Date parsing uses {@link FastDateParser} patterns, which are compatible 
with {@link java.text.SimpleDateFormat} except for time zone differences.
+ * The {@code S} pattern letter represents the millisecond field,
  * which is parsed as a whole number. For example, the pattern {@code ss.SSS} 
parses {@code 05.1} as five seconds and one millisecond.
  * Repeating {@code S} does not provide sub-millisecond precision. For 
fractional-second parsing, use
  * {@link java.time.format.DateTimeFormatter}.
@@ -1391,10 +1392,15 @@ private static Calendar modify(final Calendar val, 
final int field, final Modify
      * </p>
      * The parser will be lenient toward the parsed date.
      *
+     * <p>
+     * Patterns follow {@link FastDateParser}, including its time zone rules. 
The pattern {@code ZZ} accepts {@code Z} or a colon-separated offset
+     * such as {@code -05:00}, but not {@code -0500}. Use {@code Z} or {@code 
XX} for offsets without a colon, such as {@code -0500}.
+     * </p>
+     *
      * @param str  The date to parse, not null.
      * @param locale The locale whose date format symbols should be used. If 
{@code null},
      * the system locale is used (as per {@link #parseDate(String, 
String...)}).
-     * @param parsePatterns  The date format patterns to use, see 
SimpleDateFormat, not null.
+     * @param parsePatterns  The date format patterns to use, as defined by 
{@link FastDateParser}, not null.
      * @return The parsed date.
      * @throws NullPointerException Thrown if the date string or pattern array 
is null.
      * @throws ParseException Thrown if none of the date patterns were 
suitable (or there were none).
@@ -1414,8 +1420,13 @@ public static Date parseDate(final String str, final 
Locale locale, final String
      * </p>
      * The parser will be lenient toward the parsed date.
      *
+     * <p>
+     * Patterns follow {@link FastDateParser}, including its time zone rules. 
The pattern {@code ZZ} accepts {@code Z} or a colon-separated offset
+     * such as {@code -05:00}, but not {@code -0500}. Use {@code Z} or {@code 
XX} for offsets without a colon, such as {@code -0500}.
+     * </p>
+     *
      * @param str  The date to parse, not null.
-     * @param parsePatterns  The date format patterns to use, see 
SimpleDateFormat, not null.
+     * @param parsePatterns  The date format patterns to use, as defined by 
{@link FastDateParser}, not null.
      * @return The parsed date.
      * @throws NullPointerException Thrown if the date string or pattern array 
is null.
      * @throws ParseException Thrown if none of the date patterns were 
suitable (or there were none).
@@ -1435,10 +1446,15 @@ public static Date parseDate(final String str, final 
String... parsePatterns) th
      * </p>
      * The parser parses strictly - it does not allow for dates such as 
"February 942, 1996".
      *
+     * <p>
+     * Patterns follow {@link FastDateParser}, including its time zone rules. 
The pattern {@code ZZ} accepts {@code Z} or a colon-separated offset
+     * such as {@code -05:00}, but not {@code -0500}. Use {@code Z} or {@code 
XX} for offsets without a colon, such as {@code -0500}.
+     * </p>
+     *
      * @param str  The date to parse, not null.
      * @param locale The locale whose date format symbols should be used. If 
{@code null},
      * the system locale is used (as per {@link #parseDateStrictly(String, 
String...)}).
-     * @param parsePatterns  The date format patterns to use, see 
SimpleDateFormat, not null.
+     * @param parsePatterns  The date format patterns to use, as defined by 
{@link FastDateParser}, not null.
      * @return The parsed date.
      * @throws NullPointerException Thrown if the date string or pattern array 
is null.
      * @throws ParseException Thrown if none of the date patterns were 
suitable.
@@ -1458,8 +1474,13 @@ public static Date parseDateStrictly(final String str, 
final Locale locale, fina
      * </p>
      * The parser parses strictly - it does not allow for dates such as 
"February 942, 1996".
      *
+     * <p>
+     * Patterns follow {@link FastDateParser}, including its time zone rules. 
The pattern {@code ZZ} accepts {@code Z} or a colon-separated offset
+     * such as {@code -05:00}, but not {@code -0500}. Use {@code Z} or {@code 
XX} for offsets without a colon, such as {@code -0500}.
+     * </p>
+     *
      * @param str  The date to parse, not null.
-     * @param parsePatterns  The date format patterns to use, see 
SimpleDateFormat, not null.
+     * @param parsePatterns  The date format patterns to use, as defined by 
{@link FastDateParser}, not null.
      * @return The parsed date.
      * @throws NullPointerException Thrown if the date string or pattern array 
is null.
      * @throws ParseException Thrown if none of the date patterns were 
suitable.
@@ -1481,7 +1502,7 @@ public static Date parseDateStrictly(final String str, 
final String... parsePatt
      * @param dateStr  The date to parse, not null.
      * @param locale The locale to use when interpreting the pattern, can be 
null in which
      * case the default system locale is used.
-     * @param parsePatterns  The date format patterns to use, see 
SimpleDateFormat, not null.
+     * @param parsePatterns  The date format patterns to use, as defined by 
{@link FastDateParser}, not null.
      * @param lenient Specify whether or not date/time parsing is to be 
lenient.
      * @return The parsed date.
      * @throws NullPointerException Thrown if the date string or pattern array 
is null.

Reply via email to