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 625f3c106 Add 
DurationFormatUtilsTest.testFormatPeriodWithoutMonthsAfterLeapDayAnniversary()
625f3c106 is described below

commit 625f3c1068f2df67a749d99c5a4a48248363a6c5
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Sep 1 17:41:11 2026 -0400

    Add 
DurationFormatUtilsTest.testFormatPeriodWithoutMonthsAfterLeapDayAnniversary()
---
 .../commons/lang3/time/DurationFormatUtilsTest.java      | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git 
a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java 
b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
index 572682e9a..969ddb9dd 100644
--- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java
@@ -95,7 +95,7 @@ private void assertFormatPeriodOneMilli(final long 
startMillis, final long endMi
         assertEquals(DurationFormatUtils.formatDuration(endMillis - 
startMillis, "S"),
                 DurationFormatUtils.formatPeriod(startMillis, endMillis, "S", 
true, gmt));
     }
-
+    
     private void bruteForce(final int year, final int month, final int day, 
final String format, final int calendarType) {
         final String msg = year + "-" + month + "-" + day + " to ";
         final Calendar c = Calendar.getInstance();
@@ -576,6 +576,20 @@ void testFormatPeriodLongRangeBounds() {
         assertFormatPeriodOneMilli((long) Integer.MIN_VALUE - 1, 
Integer.MIN_VALUE);
     }
 
+    @Test
+    void testFormatPeriodWithoutMonthsAfterLeapDayAnniversary() {
+        final TimeZone timeZone = TimeZone.getTimeZone("UTC");
+        final Calendar start = Calendar.getInstance(timeZone);
+        start.clear();
+        // 2020 was not a leap year
+        start.set(2020, Calendar.FEBRUARY, 29);
+        final Calendar end = Calendar.getInstance(timeZone);
+        end.clear();
+        // 2021 was not a leap year
+        end.set(2021, Calendar.MARCH, 1);
+        assertEquals("1 years 1 days", 
DurationFormatUtils.formatPeriod(start.getTimeInMillis(), 
end.getTimeInMillis(), "y' years 'd' days'", false, timeZone));
+    }
+
     /**
      * Takes 8 seconds to run.
      */

Reply via email to