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 164b290d38323b271bfa4f3c5007323d64a7575b
Author: Gary Gregory <[email protected]>
AuthorDate: Tue Aug 4 07:57:35 2026 -0400

    Simplify Instants.toMillisSince(Instant)
---
 src/main/java/org/apache/commons/lang3/time/Instants.java | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/time/Instants.java 
b/src/main/java/org/apache/commons/lang3/time/Instants.java
index 094cb4319..69fa732c5 100644
--- a/src/main/java/org/apache/commons/lang3/time/Instants.java
+++ b/src/main/java/org/apache/commons/lang3/time/Instants.java
@@ -17,7 +17,6 @@
 
 package org.apache.commons.lang3.time;
 
-import java.time.Duration;
 import java.time.Instant;
 
 /**
@@ -87,14 +86,7 @@ public static Instant toInstant(final Instant instant, final 
Instant defaultInst
      * @return long The duration in milliseconds since the given Instant.
      */
     public static long toMillisSince(final Instant instant) {
-        // The sign of the duration is the opposite of the sign of the 
instant's epoch second: an instant far in the past
-        // yields a large positive duration, an instant far in the future a 
large negative one. Bind on the duration.
-        final Duration duration = DurationUtils.since(toInstant(instant));
-        try {
-            return duration.toMillis();
-        } catch (final ArithmeticException e) {
-            return duration.isNegative() ? Long.MIN_VALUE : Long.MAX_VALUE;
-        }
+        return 
DurationUtils.toMillisLong(DurationUtils.since(toInstant(instant)));
     }
 
     /**

Reply via email to